Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: add frozenColumnLine visible on theme #3828\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
3 changes: 2 additions & 1 deletion docs/assets/guide/en/theme_and_style/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ const theme = {
shadow: {
width: 4,
startColor: 'rgba(00, 24, 47, 0.05)',
endColor: 'rgba(00, 24, 47, 0)'
endColor: 'rgba(00, 24, 47, 0)',
visible: 'scrolling'
}
},
//菜单样式
Expand Down
3 changes: 2 additions & 1 deletion docs/assets/guide/zh/theme_and_style/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ const theme = {
shadow: {
width: 4,
startColor: 'rgba(00, 24, 47, 0.05)',
endColor: 'rgba(00, 24, 47, 0)'
endColor: 'rgba(00, 24, 47, 0)',
visible: 'scrolling'
}
},
//菜单样式
Expand Down
10 changes: 9 additions & 1 deletion docs/assets/option/en/common/frozen-column-line-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ Shadow Overall Width
Start Color

###${prefix} endColor(string)
End Color
End Color

###${prefix} visible(string)

Shadow Visible Time, default is `scrolling`.

- always: always show
- scrolling: show when scrolling

13 changes: 12 additions & 1 deletion docs/assets/option/zh/common/frozen-column-line-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@
开始颜色

###${prefix} endColor(string)
结束颜色
结束颜色

###${prefix} visible(string)
阴影显示时机,默认为 `scrolling`。

- always: 总是显示
- scrolling: 滚动时显示





44 changes: 33 additions & 11 deletions packages/vtable/src/scenegraph/component/table-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ export class TableComponent {
const shadowWidth = theme.frozenColumnLine?.shadow?.width;
const shadowStartColor = theme.frozenColumnLine?.shadow?.startColor;
const shadowEndColor = theme.frozenColumnLine?.shadow?.endColor;
const visible = theme.frozenColumnLine?.shadow?.visible;
this.frozenShadowLine = createRect({
visible: true,
visible: visible === 'always',
pickable: false,
x: 0,
y: 0,
Expand All @@ -201,7 +202,7 @@ export class TableComponent {
}
});
this.rightFrozenShadowLine = createRect({
visible: true,
visible: visible === 'always',
pickable: false,
x: 0,
y: 0,
Expand Down Expand Up @@ -651,13 +652,14 @@ export class TableComponent {
* @return {*}
*/
setFrozenColumnShadow(col: number, isRightFrozen?: boolean) {
if (col < 0) {
const colX = getColX(col, this.table, isRightFrozen);
if (col < 0 || this.table.theme.frozenColumnLine?.shadow?.visible !== 'always') {
this.frozenShadowLine.setAttributes({
visible: false
visible: false,
x: colX,
height: this.table.getDrawRange().height
});
} else {
// const colX = this.table.getColsWidth(0, col);
const colX = getColX(col, this.table, isRightFrozen);
this.frozenShadowLine.setAttributes({
visible: true,
x: colX,
Expand All @@ -672,21 +674,41 @@ export class TableComponent {
* @return {*}
*/
setRightFrozenColumnShadow(col: number) {
if (col >= this.table.colCount) {
const colX = getColX(col, this.table, true);
if (col >= this.table.colCount || this.table.theme.frozenColumnLine?.shadow?.visible !== 'always') {
this.rightFrozenShadowLine.setAttributes({
visible: false
visible: false,
x: colX - this.rightFrozenShadowLine.attribute.width,
height: this.table.getDrawRange().height
});
} else {
// const colX = this.table.getColsWidth(0, col);
const colX = getColX(col, this.table, true);
this.rightFrozenShadowLine.setAttributes({
visible: true,
x: colX - this.rightFrozenShadowLine.attribute.width,
height: this.table.getDrawRange().height
});
}
}

hideFrozenColumnShadow() {
const visible1 = this.table.theme.frozenColumnLine?.shadow?.visible;
const visible = this.table.theme.frozenColumnLine?.shadow?.visible ?? visible1;
if (visible !== 'scrolling') {
return;
}
this.frozenShadowLine.setAttribute('visible', false);
this.rightFrozenShadowLine.setAttribute('visible', false);
this.table.scenegraph.updateNextFrame();
}
showFrozenColumnShadow() {
const visible1 = this.table.theme.frozenColumnLine?.shadow?.visible;
const visible = this.table.theme.frozenColumnLine?.shadow?.visible ?? visible1;
if (visible !== 'scrolling') {
return;
}
this.frozenShadowLine.setAttribute('visible', true);
this.rightFrozenShadowLine.setAttribute('visible', true);
this.table.scenegraph.updateNextFrame();
}
hideVerticalScrollBar() {
const visible1 = this.table.theme.scrollStyle.visible;
const verticalVisible = this.table.theme.scrollStyle.verticalVisible ?? visible1;
Expand Down
2 changes: 2 additions & 0 deletions packages/vtable/src/state/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,12 @@ export class StateManager {
}
showHorizontalScrollBar(autoHide?: boolean) {
this.table.scenegraph.component.showHorizontalScrollBar();
this.table.scenegraph?.component.showFrozenColumnShadow();
if (autoHide) {
// 滚轮触发滚动条显示后,异步隐藏
clearTimeout(this._clearHorizontalScrollBar);
this._clearHorizontalScrollBar = setTimeout(() => {
this.table.scenegraph?.component.hideFrozenColumnShadow();
this.table.scenegraph?.component.hideHorizontalScrollBar();
}, 1000);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/vtable/src/themes/ARCO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export default {
shadow: {
width: 4,
startColor: 'rgba(00, 24, 47, 0.05)',
endColor: 'rgba(00, 24, 47, 0)'
endColor: 'rgba(00, 24, 47, 0)',
visible: 'always'
}
},
// menuStyle: {
Expand Down
3 changes: 2 additions & 1 deletion packages/vtable/src/themes/BRIGHT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export default {
shadow: {
width: 3,
startColor: '#CBDCFE',
endColor: '#CBDCFE'
endColor: '#CBDCFE',
visible: 'always'
}
},
// menuStyle: {
Expand Down
3 changes: 2 additions & 1 deletion packages/vtable/src/themes/DARK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default {
shadow: {
width: 4,
startColor: 'rgba(00, 24, 47, 0.05)',
endColor: 'rgba(00, 24, 47, 0)'
endColor: 'rgba(00, 24, 47, 0)',
visible: 'always'
}
},
// menuStyle: {
Expand Down
3 changes: 2 additions & 1 deletion packages/vtable/src/themes/DEFAULT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export default {
shadow: {
width: 3,
startColor: 'rgba(225, 228, 232, 0.6)',
endColor: 'rgba(225, 228, 232, 0.6)'
endColor: 'rgba(225, 228, 232, 0.6)',
visible: 'always'
}
},
// menuStyle: {
Expand Down
7 changes: 6 additions & 1 deletion packages/vtable/src/themes/theme-define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,9 @@ export class TableTheme implements ITableThemeDefine {
obj.frozenColumnLine
);
this._frozenColumnLine = {
get shadow(): { width: number; startColor: string; endColor: string } | undefined {
get shadow():
| { width: number; startColor: string; endColor: string; visible: 'always' | 'scrolling' }
| undefined {
if (frozenColumnLine.shadow) {
return {
get width(): number {
Expand All @@ -656,6 +658,9 @@ export class TableTheme implements ITableThemeDefine {
},
get endColor(): string {
return frozenColumnLine.shadow?.endColor ?? 'rgba(00, 24, 47, 0)';
},
get visible(): 'always' | 'scrolling' {
return frozenColumnLine.shadow?.visible ?? 'always';
}
};
}
Expand Down
2 changes: 2 additions & 0 deletions packages/vtable/src/ts-types/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ export interface ITableThemeDefine {
width: number; //阴影整体宽度
startColor: string; //开始颜色
endColor: string; //结束颜色
/**滚动条是否可见 'always' | 'scrolling' | 'none' | 'focus',常驻|滚动时|不显示|聚焦在画布上时 。默认'scrolling'*/
visible?: 'always' | 'scrolling';
};
/** TODO 暂未生效 */
border?: {
Expand Down
Loading