Skip to content

Commit

Permalink
Merge pull request #3485 from VisActor/fix/domain-cache-scroll
Browse files Browse the repository at this point in the history
fix: update visible when layout end
  • Loading branch information
xile611 authored Dec 4, 2024
2 parents 281f972 + 29a7478 commit 2baadd6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix: upgrade scrollbar visible after layout. fix#3452",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,15 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
super.updateLayoutAttribute();
}

onLayoutStart(layoutRect: IRect, viewRect: ILayoutRect, ctx: any): void {
super.onLayoutStart(layoutRect, viewRect, ctx);
const isShown = this._autoUpdate(layoutRect);
protected _autoVisible(isShown: boolean) {
if (!this._auto) {
return;
}
if (isShown) {
this.show();
} else {
this.hide();
}
const sizeKey = this._isHorizontal ? 'height' : 'width';
this.layout.setLayoutRect(
{
Expand All @@ -912,9 +918,22 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
[sizeKey]: AttributeLevel.Built_In
}
);
}

onLayoutStart(layoutRect: IRect, viewRect: ILayoutRect, ctx: any): void {
super.onLayoutStart(layoutRect, viewRect, ctx);
const isShown = this._autoUpdate(layoutRect);
this._autoVisible(isShown);
this._dataUpdating = false;
}

onLayoutEnd(ctx: any): void {
// 布局结束后, start和end会发生变化, 因此需要再次更新visible
const isShown = !(this._start === 0 && this._end === 1);
this._autoVisible(isShown);
super.onLayoutEnd(ctx);
}

/**
* bounds预计算
* @param rect
Expand Down Expand Up @@ -1004,11 +1023,6 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
isShown = !(start === 0 && end === 1);
}
this.setStartAndEnd(this._start, this._end);
if (isShown) {
this.show();
} else {
this.hide();
}
this._cacheVisibility = isShown;
return isShown;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ export class ScrollBar<T extends IScrollBarSpec = IScrollBarSpec> extends DataFi
}

protected _handleDataCollectionChange() {
// do nothing
if (this._spec.auto) {
const data = this._data.getDataView();
data.reRunAllTransform();
}
}

protected _initCommonEvent() {
Expand Down

0 comments on commit 2baadd6

Please sign in to comment.