@antv/g 5.16.29 → 5.16.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -9287,7 +9287,7 @@
9287
9287
  var sortable=displayObject.sortable;if(sortable.dirty){this.sort(displayObject,sortable);sortable.dirty=false;sortable.dirtyChildren=[];sortable.dirtyReason=undefined;}// recursive rendering its children
9288
9288
  (sortable.sorted||displayObject.childNodes).forEach(function(child){_this2.renderDisplayObject(child,canvasConfig,renderingContext);});};_proto.sort=function sort(displayObject,sortable){if(sortable.sorted&&sortable.dirtyReason!==exports.SortReason.Z_INDEX_CHANGED){// avoid re-sorting the whole children list
9289
9289
  sortable.dirtyChildren.forEach(function(child){var index=displayObject.childNodes.indexOf(child);if(index===-1){// remove from sorted list
9290
- var _index=sortable.sorted.indexOf(child);sortable.sorted.splice(_index,1);}else {if(sortable.sorted.length===0){sortable.sorted.push(child);}else {var _index2=sortedIndex(sortable.sorted,child);sortable.sorted.splice(_index2,0,child);}}});}else {sortable.sorted=displayObject.childNodes.slice().sort(sortByZIndex);}};_proto.destroy=function destroy(){this.inited=false;this.hooks.destroy.call();this.globalRuntime.sceneGraphService.clearPendingEvents();};_proto.dirtify=function dirtify(){// need re-render
9290
+ var _index=sortable.sorted.indexOf(child);if(_index>=0){sortable.sorted.splice(_index,1);}}else {if(sortable.sorted.length===0){sortable.sorted.push(child);}else {var _index2=sortedIndex(sortable.sorted,child);sortable.sorted.splice(_index2,0,child);}}});}else {sortable.sorted=displayObject.childNodes.slice().sort(sortByZIndex);}};_proto.destroy=function destroy(){this.inited=false;this.hooks.destroy.call();this.globalRuntime.sceneGraphService.clearPendingEvents();};_proto.dirtify=function dirtify(){// need re-render
9291
9291
  this.context.renderingContext.renderReasons.add(exports.RenderReason.DISPLAY_OBJECT_CHANGED);};return RenderingService;}();var ATTRIBUTE_REGEXP=/\[\s*(.*)=(.*)\s*\]/;/**
9292
9292
  * support the following DOM API:
9293
9293
  * * getElementById
@@ -9348,7 +9348,7 @@
9348
9348
  if(transform.localSkew[0]!==0||transform.localSkew[1]!==0){var tmpMat4=identity(tmpMat);tmpMat4[4]=Math.tan(transform.localSkew[0]);tmpMat4[1]=Math.tan(transform.localSkew[1]);multiply(transform.localTransform,transform.localTransform,tmpMat4);}var scaling=fromRotationTranslationScaleOrigin(tmpMat,tmpQuat,tmpPosition,transform.localScale,transform.origin);multiply(transform.localTransform,transform.localTransform,scaling);}else {// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
9349
9349
  fromRotationTranslationScaleOrigin(transform.localTransform,transform.localRotation,transform.localPosition,transform.localScale,transform.origin);}};}();this.runtime=runtime;}var _proto=DefaultSceneGraphService.prototype;_proto.matches=function matches(query,root){return this.runtime.sceneGraphSelector.is(query,root);};_proto.querySelector=function querySelector(query,root){return this.runtime.sceneGraphSelector.selectOne(query,root);};_proto.querySelectorAll=function querySelectorAll(query,root){return this.runtime.sceneGraphSelector.selectAll(query,root);// .filter((node) => !node.shadow);
9350
9350
  };_proto.attach=function attach(child,parent,index){var _sortable$sorted,_child$style;var detached=false;if(child.parentNode){detached=child.parentNode!==parent;this.detach(child);}child.parentNode=parent;if(!isNil(index)){child.parentNode.childNodes.splice(index,0,child);}else {child.parentNode.childNodes.push(child);}// parent needs re-sort
9351
- var sortable=parent.sortable;if((sortable===null||sortable===void 0?void 0:(_sortable$sorted=sortable.sorted)===null||_sortable$sorted===void 0?void 0:_sortable$sorted.length)||((_child$style=child.style)===null||_child$style===void 0?void 0:_child$style.zIndex)){sortable.dirtyChildren.push(child);// if (sortable) {
9351
+ var sortable=parent.sortable;if((sortable===null||sortable===void 0?void 0:(_sortable$sorted=sortable.sorted)===null||_sortable$sorted===void 0?void 0:_sortable$sorted.length)||((_child$style=child.style)===null||_child$style===void 0?void 0:_child$style.zIndex)){if(sortable.dirtyChildren.indexOf(child)===-1){sortable.dirtyChildren.push(child);}// if (sortable) {
9352
9352
  // only child has z-Index
9353
9353
  sortable.dirty=true;sortable.dirtyReason=exports.SortReason.ADDED;}// this.updateGraphDepth(child);
9354
9354
  var transform=child.transformable;if(transform){this.dirtifyWorld(child,transform);}if(transform.frozen){this.unfreezeParentToRoot(child);}if(detached){child.dispatchEvent(reparentEvent);}};_proto.detach=function detach(child){if(child.parentNode){var _sortable$sorted2,_child$style2;var transform=child.transformable;// if (transform) {
@@ -9360,7 +9360,7 @@
9360
9360
  // }
9361
9361
  // parent needs re-sort
9362
9362
  var sortable=child.parentNode.sortable;// if (sortable) {
9363
- if((sortable===null||sortable===void 0?void 0:(_sortable$sorted2=sortable.sorted)===null||_sortable$sorted2===void 0?void 0:_sortable$sorted2.length)||((_child$style2=child.style)===null||_child$style2===void 0?void 0:_child$style2.zIndex)){sortable.dirtyChildren.push(child);sortable.dirty=true;sortable.dirtyReason=exports.SortReason.REMOVED;}var index=child.parentNode.childNodes.indexOf(child);if(index>-1){child.parentNode.childNodes.splice(index,1);}if(transform){this.dirtifyWorld(child,transform);}child.parentNode=null;}};_proto.getOrigin=function getOrigin(element){return element.transformable.origin;}/**
9363
+ if((sortable===null||sortable===void 0?void 0:(_sortable$sorted2=sortable.sorted)===null||_sortable$sorted2===void 0?void 0:_sortable$sorted2.length)||((_child$style2=child.style)===null||_child$style2===void 0?void 0:_child$style2.zIndex)){if(sortable.dirtyChildren.indexOf(child)===-1){sortable.dirtyChildren.push(child);}sortable.dirty=true;sortable.dirtyReason=exports.SortReason.REMOVED;}var index=child.parentNode.childNodes.indexOf(child);if(index>-1){child.parentNode.childNodes.splice(index,1);}if(transform){this.dirtifyWorld(child,transform);}child.parentNode=null;}};_proto.getOrigin=function getOrigin(element){return element.transformable.origin;}/**
9364
9364
  * same as pivot in Pixi.js
9365
9365
  *
9366
9366
  * @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
@@ -9489,11 +9489,11 @@
9489
9489
  * @see https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/README.md
9490
9490
  *
9491
9491
  * also provide some extra events such as `drag`
9492
- */var EventPlugin=/*#__PURE__*/function(){function EventPlugin(){var _this=this;this.autoPreventDefault=false;this.rootPointerEvent=new FederatedPointerEvent(null);this.rootWheelEvent=new FederatedWheelEvent(null);this.context=void 0;this.onPointerMove=function(nativeEvent){var _this$context$renderi,_this$context$renderi2;var canvas=(_this$context$renderi=_this.context.renderingContext.root)===null||_this$context$renderi===void 0?void 0:(_this$context$renderi2=_this$context$renderi.ownerDocument)===null||_this$context$renderi2===void 0?void 0:_this$context$renderi2.defaultView;if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var normalizedEvents=_this.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator=_createForOfIteratorHelperLoose(normalizedEvents),_step;!(_step=_iterator()).done;){var normalizedEvent=_step.value;var event=_this.bootstrapEvent(_this.rootPointerEvent,normalizedEvent,canvas,nativeEvent);_this.context.eventService.mapEvent(event);}_this.setCursor(_this.context.eventService.cursor);};}var _proto=EventPlugin.prototype;_proto.apply=function apply(context){var _this2=this;this.context=context;var renderingService=context.renderingService;var canvas=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler(function(position){var _this2$context$render=_this2.context.renderingService.hooks.pickSync.call({position:position,picked:[],topmost:true// we only concern the topmost element
9493
- }),picked=_this2$context$render.picked;return picked[0]||null;});renderingService.hooks.pointerWheel.tap(EventPlugin.tag,function(nativeEvent){var wheelEvent=_this2.normalizeWheelEvent(nativeEvent);_this2.context.eventService.mapEvent(wheelEvent);});renderingService.hooks.pointerDown.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var events=_this2.normalizeToPointerEvent(nativeEvent,canvas);if(_this2.autoPreventDefault&&events[0].isNormalized){var cancelable=nativeEvent.cancelable||!('cancelable'in nativeEvent);if(cancelable){nativeEvent.preventDefault();}}for(var _iterator2=_createForOfIteratorHelperLoose(events),_step2;!(_step2=_iterator2()).done;){var event=_step2.value;var federatedEvent=_this2.bootstrapEvent(_this2.rootPointerEvent,event,canvas,nativeEvent);_this2.context.eventService.mapEvent(federatedEvent);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerUp.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;// account for element in SVG
9492
+ */var EventPlugin=/*#__PURE__*/function(){function EventPlugin(){var _this=this;this.autoPreventDefault=false;this.rootPointerEvent=new FederatedPointerEvent(null);this.rootWheelEvent=new FederatedWheelEvent(null);this.context=void 0;this.onPointerMove=function(nativeEvent){var _this$context$renderi,_this$context$renderi2;var canvas=(_this$context$renderi=_this.context.renderingContext.root)===null||_this$context$renderi===void 0?void 0:(_this$context$renderi2=_this$context$renderi.ownerDocument)===null||_this$context$renderi2===void 0?void 0:_this$context$renderi2.defaultView;if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var normalizedEvents=_this.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator=_createForOfIteratorHelperLoose(normalizedEvents),_step;!(_step=_iterator()).done;){var normalizedEvent=_step.value;var event=_this.bootstrapEvent(_this.rootPointerEvent,normalizedEvent,canvas,nativeEvent);_this.context.eventService.mapEvent(event);}_this.setCursor(_this.context.eventService.cursor);};this.onClick=function(nativeEvent){var _this$context$renderi3,_this$context$renderi4;var canvas=(_this$context$renderi3=_this.context.renderingContext.root)===null||_this$context$renderi3===void 0?void 0:(_this$context$renderi4=_this$context$renderi3.ownerDocument)===null||_this$context$renderi4===void 0?void 0:_this$context$renderi4.defaultView;var normalizedEvents=_this.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator2=_createForOfIteratorHelperLoose(normalizedEvents),_step2;!(_step2=_iterator2()).done;){var normalizedEvent=_step2.value;var event=_this.bootstrapEvent(_this.rootPointerEvent,normalizedEvent,canvas,nativeEvent);_this.context.eventService.mapEvent(event);}_this.setCursor(_this.context.eventService.cursor);};}var _proto=EventPlugin.prototype;_proto.apply=function apply(context){var _this2=this;this.context=context;var renderingService=context.renderingService;var canvas=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler(function(position){var _this2$context$render=_this2.context.renderingService.hooks.pickSync.call({position:position,picked:[],topmost:true// we only concern the topmost element
9493
+ }),picked=_this2$context$render.picked;return picked[0]||null;});renderingService.hooks.pointerWheel.tap(EventPlugin.tag,function(nativeEvent){var wheelEvent=_this2.normalizeWheelEvent(nativeEvent);_this2.context.eventService.mapEvent(wheelEvent);});renderingService.hooks.pointerDown.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var events=_this2.normalizeToPointerEvent(nativeEvent,canvas);if(_this2.autoPreventDefault&&events[0].isNormalized){var cancelable=nativeEvent.cancelable||!('cancelable'in nativeEvent);if(cancelable){nativeEvent.preventDefault();}}for(var _iterator3=_createForOfIteratorHelperLoose(events),_step3;!(_step3=_iterator3()).done;){var event=_step3.value;var federatedEvent=_this2.bootstrapEvent(_this2.rootPointerEvent,event,canvas,nativeEvent);_this2.context.eventService.mapEvent(federatedEvent);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerUp.tap(EventPlugin.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;// account for element in SVG
9494
9494
  var $element=_this2.context.contextService.getDomElement();var outside='outside';try{outside=$element&&nativeEvent.target&&nativeEvent.target!==$element&&$element.contains&&!$element.contains(nativeEvent.target)?'outside':'';}catch(e){// nativeEvent.target maybe not Node, such as Window
9495
9495
  // @see https://github.com/antvis/G/issues/1235
9496
- }var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator3=_createForOfIteratorHelperLoose(normalizedEvents),_step3;!(_step3=_iterator3()).done;){var normalizedEvent=_step3.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas,nativeEvent);event.type+=outside;_this2.context.eventService.mapEvent(event);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerMove.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOver.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOut.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.click.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerCancel.tap(EventPlugin.tag,function(nativeEvent){var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator4=_createForOfIteratorHelperLoose(normalizedEvents),_step4;!(_step4=_iterator4()).done;){var normalizedEvent=_step4.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas,nativeEvent);_this2.context.eventService.mapEvent(event);}_this2.setCursor(_this2.context.eventService.cursor);});};_proto.getViewportXY=function getViewportXY(nativeEvent){var x;var y;/**
9496
+ }var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator4=_createForOfIteratorHelperLoose(normalizedEvents),_step4;!(_step4=_iterator4()).done;){var normalizedEvent=_step4.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas,nativeEvent);event.type+=outside;_this2.context.eventService.mapEvent(event);}_this2.setCursor(_this2.context.eventService.cursor);});renderingService.hooks.pointerMove.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOver.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.pointerOut.tap(EventPlugin.tag,this.onPointerMove);renderingService.hooks.click.tap(EventPlugin.tag,this.onClick);renderingService.hooks.pointerCancel.tap(EventPlugin.tag,function(nativeEvent){var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator5=_createForOfIteratorHelperLoose(normalizedEvents),_step5;!(_step5=_iterator5()).done;){var normalizedEvent=_step5.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas,nativeEvent);_this2.context.eventService.mapEvent(event);}_this2.setCursor(_this2.context.eventService.cursor);});};_proto.getViewportXY=function getViewportXY(nativeEvent){var x;var y;/**
9497
9497
  * Should account for CSS Transform applied on container.
9498
9498
  * @see https://github.com/antvis/G/issues/1161
9499
9499
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/offsetX