UNPKG

@visactor/vrender-core

Version:

```typescript import { xxx } from '@visactor/vrender-core'; ```

62 lines (55 loc) 3.09 kB
export var UpdateCategory; !function(UpdateCategory) { UpdateCategory[UpdateCategory.NONE = 0] = "NONE", UpdateCategory[UpdateCategory.PAINT = 1] = "PAINT", UpdateCategory[UpdateCategory.SHAPE = 2] = "SHAPE", UpdateCategory[UpdateCategory.BOUNDS = 4] = "BOUNDS", UpdateCategory[UpdateCategory.TRANSFORM = 8] = "TRANSFORM", UpdateCategory[UpdateCategory.LAYOUT = 16] = "LAYOUT", UpdateCategory[UpdateCategory.PICK = 32] = "PICK"; }(UpdateCategory || (UpdateCategory = {})); export const ATTRIBUTE_CATEGORY = { fill: UpdateCategory.PAINT, opacity: UpdateCategory.PAINT, fillOpacity: UpdateCategory.PAINT, strokeOpacity: UpdateCategory.PAINT, lineDash: UpdateCategory.PAINT, lineDashOffset: UpdateCategory.PAINT, lineCap: UpdateCategory.PAINT, lineJoin: UpdateCategory.PAINT, miterLimit: UpdateCategory.PAINT, shadowColor: UpdateCategory.PAINT, x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, anchor: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, anchor3d: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, postMatrix: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS, layout: UpdateCategory.LAYOUT, zIndex: UpdateCategory.PAINT, visible: UpdateCategory.PAINT | UpdateCategory.PICK, lineWidth: UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.PICK, width: UpdateCategory.SHAPE | UpdateCategory.BOUNDS, height: UpdateCategory.SHAPE | UpdateCategory.BOUNDS }; const ATTRIBUTE_DELTA_CLASSIFIER = { stroke: (prev, next) => (null != prev && !1 !== prev) !== (null != next && !1 !== next) ? UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK : UpdateCategory.PAINT, shadowBlur: (prev, next) => { const prevBlur = Number(null != prev ? prev : 0), nextBlur = Number(null != next ? next : 0); return prevBlur !== nextBlur && (prevBlur > 0 || nextBlur > 0) ? UpdateCategory.PAINT | UpdateCategory.BOUNDS : UpdateCategory.PAINT; } }; export function classifyAttributeDelta(key, prev, next) { var _a; const dynamicClassifier = ATTRIBUTE_DELTA_CLASSIFIER[key]; return dynamicClassifier ? dynamicClassifier(prev, next) : null !== (_a = ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : UpdateCategory.PAINT; } export function classifyAffectedKeyConservatively(key) { var _a; return "stroke" === key ? UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK : "shadowBlur" === key ? UpdateCategory.PAINT | UpdateCategory.BOUNDS : null !== (_a = ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : UpdateCategory.PAINT; } export function classifyAffectedKeys(keys) { let category = UpdateCategory.NONE; for (const key of keys) category |= classifyAffectedKeyConservatively(key); return category; } //# sourceMappingURL=attribute-update-classifier.js.map