Skip to content

Commit

Permalink
feat: add scroll bar hover on display mode (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jun 14, 2023
1 parent c91c0f3 commit e4d1227
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/vtable/examples/interactive/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function createTable() {
allowFrozenColCount: 2,
theme: {
scrollStyle: {
hoverOn: true,
hoverOn: false,
scrollSliderColor: 'red',
visible: 'always'
}
Expand Down
13 changes: 9 additions & 4 deletions packages/vtable/src/scenegraph/component/table-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,13 @@ export class TableComponent {
componentGroup.addChild(this.columnResizerBgLine);
componentGroup.addChild(this.columnResizerLine);
componentGroup.addChild(this.columnResizerLabel);
componentGroup.addChild(this.hScrollBar);
componentGroup.addChild(this.vScrollBar);
if (this.table.theme.scrollStyle.hoverOn) {
componentGroup.addChild(this.hScrollBar);
componentGroup.addChild(this.vScrollBar);
} else {
componentGroup.stage.defaultLayer.addChild(this.hScrollBar);
componentGroup.stage.defaultLayer.addChild(this.vScrollBar);
}
this.menu.bindTableComponent(componentGroup);
this.drillIcon.appand(componentGroup);
this.cellMover.appand(componentGroup);
Expand Down Expand Up @@ -236,7 +241,7 @@ export class TableComponent {
const rangeEnd = Math.max(0.05, (tableWidth - frozenColsWidth) / (totalWidth - frozenColsWidth));
this.hScrollBar.setAttributes({
x: frozenColsWidth,
y: y - width,
y: y - (this.table.theme.scrollStyle.hoverOn ? width : 0),
width: tableWidth - frozenColsWidth,
range: [0, rangeEnd],
visible: visible === 'always'
Expand All @@ -255,7 +260,7 @@ export class TableComponent {
const x = Math.min(tableWidth, totalWidth);
const rangeEnd = Math.max(0.05, (tableHeight - frozenRowsHeight) / (totalHeight - frozenRowsHeight));
this.vScrollBar.setAttributes({
x: x - width,
x: x - (this.table.theme.scrollStyle.hoverOn ? width : 0),
y: frozenRowsHeight,
height: tableHeight - frozenRowsHeight,
range: [0, rangeEnd],
Expand Down

0 comments on commit e4d1227

Please sign in to comment.