@antv/g 5.16.1 → 5.16.2

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
@@ -8296,7 +8296,7 @@
8296
8296
  *
8297
8297
  * TODO: use MutationObserver instead
8298
8298
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
8299
- */(function(ElementEvent){ElementEvent["DESTROY"]="destroy";/**
8299
+ */(function(ElementEvent){ElementEvent["REPARENT"]="reparent";ElementEvent["DESTROY"]="destroy";/**
8300
8300
  * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
8301
8301
  */ElementEvent["ATTR_MODIFIED"]="DOMAttrModified";/**
8302
8302
  * it has been inserted
@@ -9225,18 +9225,18 @@
9225
9225
  return root.findAll(function(node){return root!==node&&((node===null||node===void 0?void 0:node.classList)||[]).indexOf(_this2.getIdOrClassname(query))>-1;});}else if(query.startsWith('#')){return root.findAll(function(node){return root!==node&&node.id===_this2.getIdOrClassname(query);});}else if(query.startsWith('[')){var _this$getAttribute2=this.getAttribute(query),name=_this$getAttribute2.name,value=_this$getAttribute2.value;if(name){// getElementsByName();
9226
9226
  return root.findAll(function(node){return root!==node&&(name==='name'?node.name===value:_this2.attributeToString(node,name)===value);});}else {return [];}}else {// getElementsByTag('circle');
9227
9227
  return root.findAll(function(node){return root!==node&&node.nodeName===query;});}};_proto.is=function is(query,node){// a simple `matches` implementation
9228
- if(query.startsWith('.')){return node.className===this.getIdOrClassname(query);}else if(query.startsWith('#')){return node.id===this.getIdOrClassname(query);}else if(query.startsWith('[')){var _this$getAttribute3=this.getAttribute(query),name=_this$getAttribute3.name,value=_this$getAttribute3.value;return name==='name'?node.name===value:this.attributeToString(node,name)===value;}else {return node.nodeName===query;}};_proto.getIdOrClassname=function getIdOrClassname(query){return query.substring(1);};_proto.getAttribute=function getAttribute(query){var matches=query.match(ATTRIBUTE_REGEXP);var name='';var value='';if(matches&&matches.length>2){name=matches[1].replace(/"/g,'');value=matches[2].replace(/"/g,'');}return {name:name,value:value};};_proto.attributeToString=function attributeToString(node,name){if(!node.getAttribute){return '';}var value=node.getAttribute(name);if(isNil(value)){return '';}if(value.toString){return value.toString();}return '';};return DefaultSceneGraphSelector;}();function markRenderableDirty(e){var renderable=e.renderable;if(renderable){renderable.renderBoundsDirty=true;renderable.boundsDirty=true;}}/**
9228
+ if(query.startsWith('.')){return node.className===this.getIdOrClassname(query);}else if(query.startsWith('#')){return node.id===this.getIdOrClassname(query);}else if(query.startsWith('[')){var _this$getAttribute3=this.getAttribute(query),name=_this$getAttribute3.name,value=_this$getAttribute3.value;return name==='name'?node.name===value:this.attributeToString(node,name)===value;}else {return node.nodeName===query;}};_proto.getIdOrClassname=function getIdOrClassname(query){return query.substring(1);};_proto.getAttribute=function getAttribute(query){var matches=query.match(ATTRIBUTE_REGEXP);var name='';var value='';if(matches&&matches.length>2){name=matches[1].replace(/"/g,'');value=matches[2].replace(/"/g,'');}return {name:name,value:value};};_proto.attributeToString=function attributeToString(node,name){if(!node.getAttribute){return '';}var value=node.getAttribute(name);if(isNil(value)){return '';}if(value.toString){return value.toString();}return '';};return DefaultSceneGraphSelector;}();function markRenderableDirty(e){var renderable=e.renderable;if(renderable){renderable.renderBoundsDirty=true;renderable.boundsDirty=true;}}var reparentEvent=new MutationEvent(exports.ElementEvent.REPARENT,null,'','','',0,'','');/**
9229
9229
  * update transform in scene graph
9230
9230
  *
9231
9231
  * @see https://community.khronos.org/t/scene-graphs/50542/7
9232
9232
  */var DefaultSceneGraphService=/*#__PURE__*/function(){function DefaultSceneGraphService(runtime){var _this=this;this.runtime=void 0;this.pendingEvents=[];this.boundsChangedEvent=new CustomEvent(exports.ElementEvent.BOUNDS_CHANGED);this.rotate=function(){var parentInvertRotation=create$4();return function(element,degrees,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof degrees==='number'){degrees=fromValues$2(degrees,y,z);}var transform=element.transformable;if(element.parentNode===null||!element.parentNode.transformable){_this.rotateLocal(element,degrees);}else {var rotation=create$4();fromEuler(rotation,degrees[0],degrees[1],degrees[2]);var rot=_this.getRotation(element);var parentRot=_this.getRotation(element.parentNode);copy$3(parentInvertRotation,parentRot);invert$1(parentInvertRotation,parentInvertRotation);multiply$2(rotation,parentInvertRotation,rotation);multiply$2(transform.localRotation,rotation,rot);normalize$2(transform.localRotation,transform.localRotation);_this.dirtifyLocal(element,transform);}};}();this.rotateLocal=function(){var rotation=create$4();return function(element,degrees,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof degrees==='number'){degrees=fromValues$2(degrees,y,z);}var transform=element.transformable;fromEuler(rotation,degrees[0],degrees[1],degrees[2]);mul$1(transform.localRotation,transform.localRotation,rotation);_this.dirtifyLocal(element,transform);};}();this.setEulerAngles=function(){var invParentRot=create$4();return function(element,degrees,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof degrees==='number'){degrees=fromValues$2(degrees,y,z);}var transform=element.transformable;if(element.parentNode===null||!element.parentNode.transformable){_this.setLocalEulerAngles(element,degrees);}else {fromEuler(transform.localRotation,degrees[0],degrees[1],degrees[2]);var parentRotation=_this.getRotation(element.parentNode);copy$3(invParentRot,invert$1(create$4(),parentRotation));mul$1(transform.localRotation,transform.localRotation,invParentRot);_this.dirtifyLocal(element,transform);}};}();this.translateLocal=function(){return function(element,translation,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof translation==='number'){translation=fromValues$2(translation,y,z);}var transform=element.transformable;if(equals$1(translation,create$2())){return;}transformQuat(translation,translation,transform.localRotation);add$1(transform.localPosition,transform.localPosition,translation);_this.dirtifyLocal(element,transform);};}();this.setPosition=function(){var parentInvertMatrix=create$1();var tmpPosition=create$2();return function(element,position){var transform=element.transformable;tmpPosition[0]=position[0];tmpPosition[1]=position[1];tmpPosition[2]=position[2]||0;if(equals$1(_this.getPosition(element),tmpPosition)){return;}copy$1(transform.position,tmpPosition);if(element.parentNode===null||!element.parentNode.transformable){copy$1(transform.localPosition,tmpPosition);}else {var parentTransform=element.parentNode.transformable;copy(parentInvertMatrix,parentTransform.worldTransform);invert(parentInvertMatrix,parentInvertMatrix);transformMat4(transform.localPosition,tmpPosition,parentInvertMatrix);}_this.dirtifyLocal(element,transform);};}();this.setLocalPosition=function(){var tmpPosition=create$2();return function(element,position){var transform=element.transformable;tmpPosition[0]=position[0];tmpPosition[1]=position[1];tmpPosition[2]=position[2]||0;if(equals$1(transform.localPosition,tmpPosition)){return;}copy$1(transform.localPosition,tmpPosition);_this.dirtifyLocal(element,transform);};}();this.translate=function(){var zeroVec3=create$2();var tmpVec3=create$2();var tr=create$2();return function(element,translation,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(typeof translation==='number'){translation=set$1(tmpVec3,translation,y,z);}if(equals$1(translation,zeroVec3)){return;}add$1(tr,_this.getPosition(element),translation);_this.setPosition(element,tr);};}();this.setRotation=function(){var parentInvertRotation=create$4();return function(element,rotation,y,z,w){var transform=element.transformable;if(typeof rotation==='number'){rotation=fromValues$4(rotation,y,z,w);}if(element.parentNode===null||!element.parentNode.transformable){_this.setLocalRotation(element,rotation);}else {var parentRot=_this.getRotation(element.parentNode);copy$3(parentInvertRotation,parentRot);invert$1(parentInvertRotation,parentInvertRotation);multiply$2(transform.localRotation,parentInvertRotation,rotation);normalize$2(transform.localRotation,transform.localRotation);_this.dirtifyLocal(element,transform);}};};this.displayObjectDependencyMap=new WeakMap();this.calcLocalTransform=function(){var tmpMat=create$1();var tmpPosition=create$2();var tmpQuat=fromValues$4(0,0,0,1);return function(transform){var hasSkew=transform.localSkew[0]!==0||transform.localSkew[1]!==0;if(hasSkew){fromRotationTranslationScaleOrigin(transform.localTransform,transform.localRotation,transform.localPosition,fromValues$2(1,1,1),transform.origin);// apply skew2D
9233
9233
  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
9234
9234
  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);
9235
- };_proto.attach=function attach(child,parent,index){var _sortable$sorted,_child$style;if(child.parentNode){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
9235
+ };_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
9236
9236
  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) {
9237
9237
  // only child has z-Index
9238
9238
  sortable.dirty=true;}// this.updateGraphDepth(child);
9239
- var transform=child.transformable;if(transform){this.dirtifyWorld(child,transform);}if(transform.frozen){this.unfreezeParentToRoot(child);}};_proto.detach=function detach(child){if(child.parentNode){var _sortable$sorted2,_child$style2;var transform=child.transformable;// if (transform) {
9239
+ 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) {
9240
9240
  // const worldTransform = this.getWorldTransform(child, transform);
9241
9241
  // mat4.getScaling(transform.localScale, worldTransform);
9242
9242
  // mat4.getTranslation(transform.localPosition, worldTransform);