Commit 25c7050a authored by limingzhe's avatar limingzhe

fix: 结算界面卡住

parent ba29541b
...@@ -870,7 +870,8 @@ export class RichText extends Label { ...@@ -870,7 +870,8 @@ export class RichText extends Label {
getSubTextRect(subText, targetIndex=0) { getSubTextRect(subText, targetIndex=0) {
this.isShowWordBg = true;
this.update();
const tmpLabel = new RichText(); const tmpLabel = new RichText();
...@@ -881,18 +882,20 @@ export class RichText extends Label { ...@@ -881,18 +882,20 @@ export class RichText extends Label {
tmpLabel.fontWeight = this.fontWeight; tmpLabel.fontWeight = this.fontWeight;
tmpLabel.width = this.width; tmpLabel.width = this.width;
tmpLabel.height = this.height; tmpLabel.height = this.height;
console.log('subText: ', subText);
// console.log('subText: ', subText); console.log('this.text: ', this.text);
// const indexArr = searchSubStr(this.text, subText); // const indexArr = searchSubStr(this.text, subText);
// console.log('indexArr: ', indexArr); // console.log('indexArr: ', indexArr);
// const index = indexArr[targetIndex]; // const index = indexArr[targetIndex];
const index = this.text.indexOf(subText, targetIndex); const index = this.text.indexOf(subText, targetIndex);
console.log('index: ', index);
if (!index) { if (index == -1) {
return; return;
} }
console.log('this.wordBgData: ', this.wordBgData);
// const index = this.text.indexOf(subText); // const index = this.text.indexOf(subText);
// console.log('!!!index: ', index); // console.log('!!!index: ', index);
...@@ -2122,7 +2125,8 @@ export class ScrollView extends MySprite { ...@@ -2122,7 +2125,8 @@ export class ScrollView extends MySprite {
refreshContentSize() { refreshContentSize() {
const children = this.content.children; const children = this.content.children;
console.log('children: ', children); // console.log('children: ', children);
let maxW = 0; let maxW = 0;
let maxH = 0; let maxH = 0;
...@@ -2131,11 +2135,11 @@ export class ScrollView extends MySprite { ...@@ -2131,11 +2135,11 @@ export class ScrollView extends MySprite {
continue; continue;
} }
const box = children[i].getBoundingBox(); const box = children[i].getBoundingBox();
console.log('box: ', box); // console.log('box: ', box);
const boxEdgeX = box.x + box.width; const boxEdgeX = box.x + box.width;
const boxEdgeY = box.y + box.height; const boxEdgeY = box.y + box.height;
console.log('boxEdgeY: ', boxEdgeY); // console.log('boxEdgeY: ', boxEdgeY);
if (boxEdgeX > maxW) { if (boxEdgeX > maxW) {
maxW = boxEdgeX; maxW = boxEdgeX;
} }
...@@ -2144,11 +2148,15 @@ export class ScrollView extends MySprite { ...@@ -2144,11 +2148,15 @@ export class ScrollView extends MySprite {
} }
} }
console.log('maxW: ', maxW); // console.log('maxW: ', maxW);
console.log('maxH: ', maxH); // console.log('maxH: ', maxH);
// console.log('this.y: ', this.y);
// console.log(this.getBoundingBox().height);
this.content.width = maxW; this.content.width = maxW;
this.content.height = maxH ; this.content.height = maxH ;
this.refreshScrollBar(); this.refreshScrollBar();
} }
...@@ -2159,6 +2167,7 @@ export class ScrollView extends MySprite { ...@@ -2159,6 +2167,7 @@ export class ScrollView extends MySprite {
setContentScale(s) { setContentScale(s) {
this.content.setScaleXY( 1 / s); this.content.setScaleXY( 1 / s);
this.refreshScrollBar();
} }
refreshScrollBar() { refreshScrollBar() {
...@@ -2167,14 +2176,20 @@ export class ScrollView extends MySprite { ...@@ -2167,14 +2176,20 @@ export class ScrollView extends MySprite {
w = this.width / 50; w = this.width / 50;
} }
let rate = this.height * this.scaleY / this.content.height / this.content.scaleY;
const rect1 = this.getBoundingBox();
const rect2 = this.content.getBoundingBox();
// let rate = rect1.height / rect2.height;
let rate = this.height / this.content.height;
// let rate = this.height * this.scaleY / this.content.height / this.content.scaleY;
if (rate >= 1) { if (rate >= 1) {
this._scrollBar.visible = false; this._scrollBar.visible = false;
rate = 1; rate = 1;
} else { } else {
this._scrollBar.visible = true; this._scrollBar.visible = true;
} }
const h = rate * this.height const h = rate * (this.height)
const r = w / 2; const r = w / 2;
this._scrollBar.setSize(w, h, r); this._scrollBar.setSize(w, h, r);
...@@ -2182,7 +2197,12 @@ export class ScrollView extends MySprite { ...@@ -2182,7 +2197,12 @@ export class ScrollView extends MySprite {
} }
refreshScrollBarPos() { refreshScrollBarPos() {
this._scrollBar.y = -this.content.y * ( this.height / this.content.height ); const rect1 = this.getBoundingBox();
const rect2 = this.content.getBoundingBox();
let rate = rect1.height / rect2.height;
this._scrollBar.y = -rect2.y * (rate );
} }
...@@ -2212,9 +2232,12 @@ export class ScrollView extends MySprite { ...@@ -2212,9 +2232,12 @@ export class ScrollView extends MySprite {
} }
onTouchMove(x, y) { onTouchMove(x, y) {
if (!this.touchStartPos) { if (!this.touchStartPos) {
return; return;
} }
if (!this.touchStartContentPos) { if (!this.touchStartContentPos) {
return; return;
} }
...@@ -2222,10 +2245,12 @@ export class ScrollView extends MySprite { ...@@ -2222,10 +2245,12 @@ export class ScrollView extends MySprite {
const offsetX = x - this.touchStartPos.x; const offsetX = x - this.touchStartPos.x;
const offsetY = y - this.touchStartPos.y; const offsetY = y - this.touchStartPos.y;
const rect = this.getBoundingBox();
if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) { if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) {
this.content.y = between(this.touchStartContentPos.y + offsetY, 0, this.getBoundingBox().height - this.content.height); this.content.y = between(this.touchStartContentPos.y + offsetY, 0, -rect.y + rect.height - this.content.height);
} else { } else {
this.content.x = between(this.touchStartContentPos.x + offsetX, 0, this.getBoundingBox().width - this.content.width); this.content.x = between(this.touchStartContentPos.x + offsetX, 0, -rect.x + rect.width - this.content.width);
} }
this.refreshScrollBarPos(); this.refreshScrollBarPos();
} }
...@@ -2239,10 +2264,12 @@ export class ScrollView extends MySprite { ...@@ -2239,10 +2264,12 @@ export class ScrollView extends MySprite {
if (!this._scrollBar.visible) { if (!this._scrollBar.visible) {
return; return;
} }
const rect = this.getBoundingBox();
if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) { if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) {
this.content.y = between(this.content.y + 40, 0, this.getBoundingBox().height - this.content.height); this.content.y = between(this.content.y + 40, 0, -rect.y + rect.height - this.content.height);
} else { } else {
this.content.x = between(this.content.x + 40, 0, this.getBoundingBox().width - this.content.width); this.content.x = between(this.content.x + 40, 0, -rect.x + rect.width - this.content.width);
} }
this.refreshScrollBarPos(); this.refreshScrollBarPos();
...@@ -2252,10 +2279,13 @@ export class ScrollView extends MySprite { ...@@ -2252,10 +2279,13 @@ export class ScrollView extends MySprite {
if (!this._scrollBar.visible) { if (!this._scrollBar.visible) {
return; return;
} }
const rect = this.getBoundingBox();
if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) { if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) {
this.content.y = between(this.content.y - 40, 0, this.getBoundingBox().height - this.content.height); this.content.y = between(this.content.y - 40, 0, -rect.y + rect.height - this.content.height);
} else { } else {
this.content.x = between(this.content.x - 40, 0, this.getBoundingBox().width - this.content.width); this.content.x = between(this.content.x - 40, 0, -rect.x + rect.width - this.content.width);
} }
this.refreshScrollBarPos(); this.refreshScrollBarPos();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment