StructV2/dist/sv.js

1 line
214 KiB
JavaScript
Raw Normal View History

2021-01-28 09:01:16 +00:00
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var r in i)("object"==typeof exports?exports:t)[r]=i[r]}}(window,(function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=15)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=i(2),n=i(1),a=i(7),s=i(17),o=i(18),h=i(19),l=i(20);var u;!function(t){t[t.IMMED=0]="IMMED",t[t.TICK=1]="TICK",t[t.ANIMATED=2]="ANIMATED"}(u=e.zrenderUpdateType||(e.zrenderUpdateType={}));class c{constructor(t,e,i){this.zr=null,this.animatePropsQueue=[],this.lastAnimatePropsQueue=[],this.propsQueue=[],this.isLastUpdateInterrupt=!1,this.viewModel=e,this.zr=c.zrender.init(t),this.animations=new h.Animations(i.animation),this.globalShape=new s.GlobalShape(this),this.offscreen=new l.OffScreen(this.globalShape.id,this),this.viewOption=i,this.container=t,this.containerWidth=t.offsetWidth,this.containerHeight=t.offsetHeight,this.zr.add(this.globalShape.getZrenderShape())}setAttribute(t,e,i){let a=this.viewOption.animation.enableAnimation,s=t instanceof r.Shape?t.zrenderShape:t.getZrenderShape();if(null!==s){if(void 0===i&&(i=a?u.ANIMATED:u.TICK),i===u.TICK||i===u.ANIMATED){let t=i===u.ANIMATED?this.animatePropsQueue:this.propsQueue,r=t.find(t=>s.id===t.zrenderShape.id);r?n.Util.extends(r.props,e):t.push({zrenderShape:s,props:e})}else s.attr(e);this.offscreen.update(t.id,e)}}renderZrenderShapes(t,e){let i,s;for(s=0;s<t.length;s++)i=t[s],i.mountState===r.mountState.NEEDMOUNT&&(null===i.zrenderShape?i.zrenderShape=i.createZrenderShape():i instanceof a.Text&&i.updateText(),this.globalShape.add(i),i.updateZrenderShape("hide",{type:u.IMMED}),i.mountState=r.mountState.MOUNTED,i.visible=!0,i.updateZrenderShape("show")),i.zrenderShape.svShape=i,i.zrenderShape.attr("z",i.option.zIndex);e.length&&e.map(t=>{t.mountState===r.mountState.NEEDUNMOUNT&&(t.mountState=r.mountState.UNMOUNTED,t.visible=!1,t.updateZrenderShape("hide",{fn:(t=>()=>{this.globalShape.remove(t),n.Util.removeFromList(this.viewModel.getShapeList(),e=>t.id===e.id)})(t)}),this.getOffScreen().remove(t.id))})}updateZrenderShapes(t){let e=this.viewOption.animation;this.propsQueue.length&&(this.propsQueue.map(t=>{Object.keys(t.props).map(e=>{"callback"!==e&&t.zrenderShape.attr(e,t.props[e])}),t.props.callback&&t.props.callback()}),this.propsQueue.length=0,!1===e.enableAnimation&&t&&t()),setTimeout(()=>{if(this.animatePropsQueue.length){this.lastAnimatePropsQueue=this.animatePropsQueue,this.animatePropsQueue=[];let i=this.lastAnimatePropsQueue,r=i.length;i.map((n,a)=>{n.zrenderShape.animateTo(n.props,e.duration,e.timingFunction,()=>{a===r-1&&!1===this.isLastUpdateInterrupt&&(i.length=0,t&&t()),n.props.callback&&n.props.callback()})})}},0)}skipUpdateZrenderShapes(t){this.lastAnimatePropsQueue.length&&(this.isLastUpdateInterrupt=!0,this.lastAnimatePropsQueue.map(t=>{t.zrenderShape.stopAnimation(!0),t.props.callback&&t.props.callback()}),t&&t(),this.lastAnimatePropsQueue.length=0,this.isLastUpdateInterrupt=!1)}resizeGlobalShape(t){if(this.viewModel.isViewUpdating)return;let e="auto"===t.width?this.container.offsetWidth:t.width,i="auto"===t.height?this.c