Skip to content

Commit

Permalink
Merge pull request #1345 from VisActor/fix/shadow-root-picker
Browse files Browse the repository at this point in the history
Fix/shadow root picker
  • Loading branch information
xile611 authored Aug 6, 2024
2 parents fbb37e2 + 7301fb5 commit f7cb2d2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: fix picker of shadow root group\n\n",
"type": "none",
"packageName": "@visactor/vrender-core"
}
],
"packageName": "@visactor/vrender-core",
"email": "[email protected]"
}
1 change: 1 addition & 0 deletions packages/vrender-core/src/graphic/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const DefaultAttribute: Required<IGraphicAttribute> = {
globalZIndex: 1,
globalCompositeOperation: '',
overflow: 'hidden',
shadowPickMode: 'graphic',
...DefaultDebugAttribute,
...DefaultStyle,
...DefaultTransform
Expand Down
1 change: 1 addition & 0 deletions packages/vrender-core/src/interface/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export type IGraphicAttribute = IDebugType &
*/
keepDirIn3d?: boolean;
shadowRootIdx: number;
shadowPickMode?: 'full' | 'graphic';
globalZIndex: number;
globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';
// 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动
Expand Down
5 changes: 4 additions & 1 deletion packages/vrender-core/src/picker/pick-interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
PickResult
} from '../interface';
import { matrixAllocate } from '../allocator/matrix-allocate';
import { getTheme } from '../graphic';

// 拦截器
export const PickItemInterceptor = Symbol.for('PickItemInterceptor');
Expand Down Expand Up @@ -73,6 +74,8 @@ export class ShadowRootPickItemInterceptorContribution implements IPickItemInter
const context = pickerService.pickContext;
context.highPerformanceSave();

const theme = (getTheme(graphic) as any)?.[graphic.type];
const { shadowPickMode = theme?.shadowPickMode } = graphic.attribute;
const g = graphic.shadowRoot;
const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);
const newPoint = new Point(
Expand All @@ -95,7 +98,7 @@ export class ShadowRootPickItemInterceptorContribution implements IPickItemInter
context.highPerformanceRestore();

// 影子节点pick到group也算pick到graphic
if (!result.graphic && result.group) {
if (!result.graphic && result.group && shadowPickMode === 'full') {
result.graphic = result.group;
}

Expand Down

0 comments on commit f7cb2d2

Please sign in to comment.