Skip to content

Commit

Permalink
feat: support overflow of mark
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Dec 5, 2024
1 parent e1b2f41 commit 8530a70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/vgrammar-core/src/types/mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export interface IMarkConfig {
* set graphic name
*/
graphicName?: string | ((element: IElement) => string);
overflow?: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';
}

/**
Expand Down
14 changes: 12 additions & 2 deletions packages/vgrammar-core/src/view/mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ export class Mark extends GrammarBase implements IMark {
'skipTheme',
'enableSegments',
'stateSort',
'graphicName'
'graphicName',
'overflow'
];
if (config === null) {
keys.forEach(key => {
Expand Down Expand Up @@ -637,7 +638,8 @@ export class Mark extends GrammarBase implements IMark {
if (!this.graphicItem) {
const graphicItem = createGraphicItem(this, GrammarMarkType.group, {
pickable: false,
zIndex: this.spec.zIndex ?? 0
zIndex: this.spec.zIndex ?? 0,
overflow: this.spec.overflow
}) as IGroup;
if (this.spec.support3d || (Mark3DType as string[]).includes(this.markType)) {
graphicItem.setMode('3d');
Expand All @@ -651,6 +653,10 @@ export class Mark extends GrammarBase implements IMark {
}
} else {
this.graphicParent = groupGraphicItem;

this.graphicParent.setAttributes({
overflow: this.spec.overflow
});
}
this.graphicIndex = markIndex;
}
Expand Down Expand Up @@ -684,6 +690,10 @@ export class Mark extends GrammarBase implements IMark {
}
}

if (!isNil(spec.overflow)) {
this.graphicItem.setAttribute('overflow', spec.overflow);
}

// only update interactive
this.elementMap.forEach(element => {
element.updateGraphicItem();
Expand Down

0 comments on commit 8530a70

Please sign in to comment.