@visactor/vrender-core
Version:
```typescript import { xxx } from '@visactor/vrender-core'; ```
68 lines (60 loc) • 3.54 kB
JavaScript
;
var UpdateCategory;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.classifyAffectedKeys = exports.classifyAffectedKeyConservatively = exports.classifyAttributeDelta = exports.ATTRIBUTE_CATEGORY = exports.UpdateCategory = void 0,
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 = exports.UpdateCategory || (exports.UpdateCategory = {})), exports.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;
}
};
function classifyAttributeDelta(key, prev, next) {
var _a;
const dynamicClassifier = ATTRIBUTE_DELTA_CLASSIFIER[key];
return dynamicClassifier ? dynamicClassifier(prev, next) : null !== (_a = exports.ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : UpdateCategory.PAINT;
}
function classifyAffectedKeyConservatively(key) {
var _a;
return "stroke" === key ? UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK : "shadowBlur" === key ? UpdateCategory.PAINT | UpdateCategory.BOUNDS : null !== (_a = exports.ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : UpdateCategory.PAINT;
}
function classifyAffectedKeys(keys) {
let category = UpdateCategory.NONE;
for (const key of keys) category |= classifyAffectedKeyConservatively(key);
return category;
}
exports.classifyAttributeDelta = classifyAttributeDelta, exports.classifyAffectedKeyConservatively = classifyAffectedKeyConservatively,
exports.classifyAffectedKeys = classifyAffectedKeys;
//# sourceMappingURL=attribute-update-classifier.js.map