1 line
16 KiB
JSON
1 line
16 KiB
JSON
|
{"ast":null,"code":"import \"core-js/modules/es.array.slice.js\";\nimport \"core-js/modules/es.array.splice.js\";\nimport * as util from './core/util.js';\nimport timsort from './core/timsort.js';\nimport { REDRAW_BIT } from './graphic/constants.js';\nvar invalidZErrorLogged = false;\n\nfunction logInvalidZError() {\n if (invalidZErrorLogged) {\n return;\n }\n\n invalidZErrorLogged = true;\n console.warn('z / z2 / zlevel of displayable is invalid, which may cause unexpected errors');\n}\n\nfunction shapeCompareFunc(a, b) {\n if (a.zlevel === b.zlevel) {\n if (a.z === b.z) {\n return a.z2 - b.z2;\n }\n\n return a.z - b.z;\n }\n\n return a.zlevel - b.zlevel;\n}\n\nvar Storage = function () {\n function Storage() {\n this._roots = [];\n this._displayList = [];\n this._displayListLen = 0;\n this.displayableSortFunc = shapeCompareFunc;\n }\n\n Storage.prototype.traverse = function (cb, context) {\n for (var i = 0; i < this._roots.length; i++) {\n this._roots[i].traverse(cb, context);\n }\n };\n\n Storage.prototype.getDisplayList = function (update, includeIgnore) {\n includeIgnore = includeIgnore || false;\n var displayList = this._displayList;\n\n if (update || !displayList.length) {\n this.updateDisplayList(includeIgnore);\n }\n\n return displayList;\n };\n\n Storage.prototype.updateDisplayList = function (includeIgnore) {\n this._displayListLen = 0;\n var roots = this._roots;\n var displayList = this._displayList;\n\n for (var i = 0, len = roots.length; i < len; i++) {\n this._updateAndAddDisplayable(roots[i], null, includeIgnore);\n }\n\n displayList.length = this._displayListLen;\n timsort(displayList, shapeCompareFunc);\n };\n\n Storage.prototype._updateAndAddDisplayable = function (el, clipPaths, includeIgnore) {\n if (el.ignore && !includeIgnore) {\n return;\n }\n\n el.beforeUpdate();\n el.update();\n el.afterUpdate();\n var userSetClipPath = el.getClipPath();\n\n if (el.ignoreClip) {\n clipPaths = null;\n } else if (userSetClipPath) {\n if (clipPaths) {\n clipPaths = clipPaths.slice();\n } else {\n clipPaths = [];\n }\n\n var currentClipPath = userSetClipPath;\n var parentClipPath = el;\n\n while (currentClipPath) {\n currentClipPath.parent = parentClipPath;\n currentClipPath.updateTransform();\n clipPaths.push(currentClipPath);\n parentClipPath = currentClipPath;\n currentClipPath = currentClipPath.getClipPath();\n }\n }\n\n if (el.childrenRef) {\n var children = el.childrenRef();\n\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n\n if (el.__dirty) {\n child.__dirty |= REDRAW_BIT;\n }\n\n this._updateAndAddDisplayable(child, clipPaths, includeIgnore);\n }\n\n el.__dirty = 0;\n } else {\n var disp = el;\n\n if (clipPaths && clipPaths.length) {\n disp.__clipPaths = clipPaths;\n } else if (disp.__clipPaths && disp.__clipPaths.length > 0) {\n disp.__clipPaths = [];\n }\n\n if (isNaN(disp.z)) {\n logInvalidZError();\n disp.z = 0;\n }\n\n if (isNaN(disp.z2)) {\n logInvalidZError();\n disp.z2 = 0;\n }\n\n if (isNaN(disp.zlevel)) {\n logInvalidZError();\n disp.zlevel = 0;\n }\n\n this._displayList[this._displayListLen++] = disp;\n }\n\n var decalEl = el.getDecalElement && el.getDecalElement();\n\n if (decalEl) {\n this._updateAndAddDisplayable(decalEl, clipPaths, includeIgnore);\n }\n\n var textGuide = el.getTextGuideLine();\n\n if (textGuide) {\n this._updateAndAddDisplayable(textGuide, clipPaths, includeIgnore);\n }\n\n var textEl = el.getTextContent();\n\n if (textEl) {\n this._updateAndAddDisplayable(textEl, clipPaths, includeIgnore);\n }\n };\n\n Storage.prototype.addRoot = function (el) {\n if (el.__zr && el.__zr.storage === this) {\n return;\n
|