isometric-css
Advanced tools
Comparing version 2.2.0 to 2.2.1
# Changelog | ||
## [2.2.1] - 2021-05-27 | ||
- Fix a bug animation elements already positioned | ||
## [2.2.0] - 2021-05-27 | ||
@@ -4,0 +8,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["isometric-css"]=e():t["isometric-css"]=e()}(this,(function(){return(()=>{"use strict";var t={158:function(t,e,n){var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var r=n(539),a=n(228),o=n(995),s=function(){function t(){this._elements=new Map,this._classes=new Map,this._keyframes=new Map,this._styles=new o.Styles}return t.prototype.hasAnimation=function(t){var e=this._elements.get(t);return!(!e||!e.keyframesName)},t.prototype.removeClasses=function(t,e){t.classList.remove(e);var n=this._classes.get(e),i=n.findIndex((function(e){return e===t}));n.splice(i,1),0===n.length&&(this._classes.delete(e),this._styles.remove(e))},t.prototype.removeKeyframes=function(t,e){var n=this._keyframes.get(e),i=n.findIndex((function(e){return e===t}));n.splice(i,1),0===n.length&&(this._keyframes.delete(e),this._styles.remove(e))},t.prototype.process=function(t,e){var n=this._elements.get(t),i=this._styles.getRuleData(e);if(i){var r={plane:e,selector:i.selector,rule:i.rule};if(n){if(n.selector===i.selector&&n.keyframesName===i.keyframesName)return;this.removeClasses(t,n.selector),n.keyframesName&&this.removeKeyframes(t,n.keyframesName)}t.classList.add(i.selector);var a=this._classes.get(i.selector);if(a?a.push(t):(this._styles.insert(i.selector,i.declaration),this._classes.set(i.selector,[t])),i.keyframesName&&i.keyframesDeclaration){var o=this._keyframes.get(i.keyframesName);o?o.push(t):(this._styles.insertKeyframes(i.keyframesName,i.keyframesDeclaration),this._keyframes.set(i.keyframesName,[t])),r.keyframes=i.keyframes,r.keyframesName=i.keyframesName}this._elements.set(t,r)}},t.prototype.addElement=function(t){var e=r.getPlaneFromElement(t);this.process(t,e)},t.prototype.removeElement=function(t){r.resetElementIsometricData(t);var e=this._elements.get(t);e&&(this._elements.delete(t),this.removeClasses(t,e.selector),e.keyframesName&&this.removeKeyframes(t,e.keyframesName))},t.prototype.setElementView=function(t,e){if(a.validView(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{view:e}):{view:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementPosition=function(t,e){if(a.validPosition(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{position:i(i({},n.plane.position),e)}):{position:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementRotation=function(t,e){if(a.validRotation(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{rotation:e}):{rotation:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementTexture=function(t,e){if(a.validTexture(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{texture:i(i({},n.plane.texture),e)}):{texture:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementAnimation=function(t,e){if(a.validAnimation(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{animation:n.plane.animation?i(i({},n.plane.animation),e):e}):{animation:e,parentRotations:r.getParentRotations(t)})}},t.prototype.resetAnimation=function(t){if(this.hasAnimation(t)){var e=t.className;t.className="",t.offsetWidth,t.className=e}},t.prototype.pauseAnimation=function(t){this.hasAnimation(t)&&(t.dataset.animationRunning="false")},t.prototype.resumeAnimation=function(t){this.hasAnimation(t)&&(t.dataset.animationRunning="true")},t}();e.default=new s},995:function(t,e,n){var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Styles=void 0;var r=n(821),a=n(37),o=n(821),s=n(854),l=n(361),u=function(){function t(){this._globalStyle=null,this._style=null,this.scale=s.round(a.SCALE),this.P50="50%",this.transformBefore="translate(-"+this.P50+", -"+this.P50+")",this.tranformAfterTop="translate(-"+this.P50+", "+this.P50+")",this.transformAfterFront="translate(-"+this.P50+", -"+this.P50+")",this.transformAfterSide="translate("+this.P50+", -"+this.P50+")",this.baseDeclarations={position:"absolute"},this.transformOriginDeclarations={transformOrigin:this.P50+" "+this.P50,MsTransformOrigin:this.P50+" "+this.P50,WebkitTransformOrigin:this.P50+" "+this.P50}}return Object.defineProperty(t.prototype,"sheet",{get:function(){return this._style?this._style.sheet:null},enumerable:!1,configurable:!0}),t.prototype.getTransform=function(t,e,n){var i=l.getViewMatrix(t,e,n);if(!i)return null;var r="matrix("+s.round(i[0][0])+","+s.round(i[1][0])+","+s.round(i[0][1])+","+s.round(i[1][1])+",0,0)",o=this.transformBefore+" "+r+" scale("+this.scale+")";switch(t){case a.VIEW.top:return o+" "+this.tranformAfterTop;case a.VIEW.front:return o+" "+this.transformAfterFront;case a.VIEW.side:return o+" "+this.transformAfterSide}},t.prototype.insertGlobalStyles=function(){this._globalStyle.sheet.insertRule('[data-animation][data-animation-running="false"] {\n animation-play-state: paused;\n }')},t.prototype.init=function(){var t=document.getElementsByTagName("head")[0];this._globalStyle=document.createElement("style"),this._style=document.createElement("style"),this._globalStyle.dataset.isometricGlobal="",this._style.dataset.isometric="",t.appendChild(this._globalStyle),t.appendChild(this._style),this.insertGlobalStyles()},t.prototype.getKeyframes=function(t){if(t.animation){var e=t.position?s.isometricToPoint(t.position,t.parentRotations):{x:0,y:0},n=s.isometricToPoint(t.animation.position,t.parentRotations);return{from:{left:e.x+"px",top:e.y+"px"},to:{left:n.x+"px",top:n.y+"px"}}}return null},t.prototype.getRule=function(t,e){var n=this.getTransform(t.view,t.parentRotations,t.rotation),r=n?i(i(i({},this.baseDeclarations),this.transformOriginDeclarations),{transform:n,MsTransform:n,WebkitTransform:n}):t.position||t.texture||t.animation&&e?i({},this.baseDeclarations):{};if(t.position){var a=s.isometricToPoint(t.position,t.parentRotations);r.left=a.x+"px",r.top=a.y+"px"}return t.texture&&(r.backgroundImage='url("'+t.texture.url+'")',r.backgroundSize=t.texture.size||"cover",t.texture.pixelated&&(r.MsInterpolationMode="nearest-neighbor",r.imageRendering="pixelated",r.fallbacks=[{imageRendering:"crisp-edges"}])),t.animation&&e&&(r.animationName=e,r.animationDuration=t.animation.duration?t.animation.duration+"ms":"1000ms",r.animationTimingFunction=t.animation.easing||"linear",r.animationIterationCount=t.animation.repeat?t.animation.bounce?""+2*t.animation.repeat:""+t.animation.repeat:"infinite",r.animationDirection=t.animation.bounce?"alternate":"normal",r.animationFillMode="both"),r},t.prototype.getDeclarationString=function(t){var e=this;return Object.entries(t).reduce((function(t,n){return Array.isArray(n[1])?""+t+n[1].map((function(t){return e.getDeclarationString(t)})).join("\n"):"object"==typeof n[1]?t+"\n"+o.kebab(n[0])+" {"+e.getDeclarationString(n[1])+"\n}":t+"\n "+o.kebab(n[0])+": "+n[1]+";"}),"")},t.prototype.getSelector=function(t){return a.NAMESPACE+"-"+r.hash(t)},t.prototype.getRuleData=function(t){var e=this.getKeyframes(t),n=e?this.getDeclarationString(e):null,i=n?this.getSelector(n):null,r=this.getRule(t,i);if(Object.keys(r).length){var a=this.getDeclarationString(r),o={rule:r,declaration:a,selector:this.getSelector(a)};return e&&(o.keyframes=e,o.keyframesDeclaration=n,o.keyframesName=i),o}return null},t.prototype.insert=function(t,e){this.sheet||this.init(),this.sheet.insertRule("."+t+" {\n"+e+"\n}")},t.prototype.insertKeyframes=function(t,e){this.sheet.insertRule("@keyframes "+t+" {\n"+e+"\n}")},t.prototype.remove=function(t){var e=this;Array.prototype.some.call(this.sheet.cssRules,(function(n,i){return("name"in n&&n.name===t||"selectorText"in n&&n.selectorText.slice(1)===t)&&(e.sheet.deleteRule(i),!0)}))},t}();e.Styles=u},37:(t,e)=>{var n,i;Object.defineProperty(e,"__esModule",{value:!0}),e.TYPE_UNDEFINED=e.AXIS=e.VIEW=e.EASING_REG_EXP=e.PROPS_REG_EXP=e.ROT_CMA=e.ROT_45=e.ROT_60=e.SCALE=e.HSQRT3=e.DECIMALS=e.NAMESPACE=void 0,e.NAMESPACE="isometric",e.DECIMALS=6,e.HSQRT3=+(Math.sqrt(3)/2).toFixed(e.DECIMALS),e.SCALE=Math.sqrt(1.5),e.ROT_60=Math.PI/3,e.ROT_45=Math.PI/4,e.ROT_CMA=Math.atan(Math.SQRT2),e.PROPS_REG_EXP=/(?: |,|^)((?:right|left|top)+)\s*:\s*((?:\d+)?\.\d+|\d+)(?= |,|$)/g,e.EASING_REG_EXP=/^((ease(-in|-out|-in-out)?)|linear|(step(-start|-end)))$/,(i=e.VIEW||(e.VIEW={})).top="top",i.front="front",i.side="side",(n=e.AXIS||(e.AXIS={})).right="right",n.left="left",n.top="top",e.TYPE_UNDEFINED="undefined"},607:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IsometricCSS=void 0;var i=n(37),r=n(158);e.IsometricCSS={processDOM:function(){Array.prototype.forEach.call(document.querySelectorAll("."+i.NAMESPACE),(function(t){r.default.addElement(t)}))},processElement:function(t){r.default.addElement(t)},resetElement:function(t){r.default.removeElement(t)},setView:function(t,e){r.default.setElementView(t,e)},setRotation:function(t,e){r.default.setElementRotation(t,e)},setPosition:function(t,e){r.default.setElementPosition(t,e)},setTexture:function(t,e){r.default.setElementTexture(t,e)},setAnimation:function(t,e){r.default.setElementAnimation(t,e)},resetAnimation:function(t){r.default.resetAnimation(t)},pauseAnimation:function(t){r.default.pauseAnimation(t)},resumeAnimation:function(t){r.default.resumeAnimation(t)}},typeof window!==i.TYPE_UNDEFINED&&typeof document!==i.TYPE_UNDEFINED&&(window.IsometricCSS=e.IsometricCSS,window.addEventListener("DOMContentLoaded",(function(){e.IsometricCSS.processDOM()})))},539:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resetElementIsometricData=e.getPlaneFromElement=e.getAnimation=e.getParentRotations=void 0;var i=n(37),r=n(228);e.getParentRotations=function(t){for(var e=[];t.parentElement&&t.parentElement!==document.documentElement;){var n=t.parentElement;n.classList.contains(i.NAMESPACE)&&!n.dataset.view&&n.dataset.rotationAxis&&e.push({axis:n.dataset.rotationAxis,value:+(n.dataset.rotationValue||0)}),t=t.parentElement}return e},e.getAnimation=function(t,e,n,a,o){if(t){for(var s={},l=void 0;null!==(l=i.PROPS_REG_EXP.exec(t));){var u=l[1],c=+l[2];s[u]=c}if(Object.keys(s).length){var f={position:s,repeat:a&&+a>0?+a:0,bounce:o&&"true"===o.trim()};return n&&i.EASING_REG_EXP.test(n.trim())&&(f.easing=n.trim()),r.validNumber(e)&&(f.duration=+e),f}}return null},e.getPlaneFromElement=function(t){var n=t.dataset,i=n.view?n.view:null,r=+(n.right||0),a=+(n.left||0),o=+(n.top||0),s=n.rotationAxis?n.rotationAxis:null,l=+(n.rotationValue||0),u=n.texture,c=n.textureSize||"cover",f="true"===n.texturePixelated,m=e.getParentRotations(t),d=e.getAnimation(n.animation,n.animationDuration,n.animationEasing,n.animationRepeat,n.animationBounce),p={parentRotations:m};return i&&(p.view=i),(r||a||o)&&(p.position={right:r,left:a,top:o}),s&&l&&(p.rotation={axis:s,value:l}),u&&(p.texture={url:u,size:c,pixelated:f}),d&&(p.animation=d),p},e.resetElementIsometricData=function(t){t.classList.remove(i.NAMESPACE),function(t,e){["view","right","left","top","rotationAxis","rotationValue","texture","textureSize","texturePixelated","animation","animationDuration","animationEasing","animationRepeat","animationBounce","animationRunning"].forEach((function(e){t.dataset[e]&&delete t.dataset[e]}))}(t)}},854:function(t,e,n){var i=this&&this.__spreadArray||function(t,e){for(var n=0,i=e.length,r=t.length;n<i;n++,r++)t[r]=e[n];return t};Object.defineProperty(e,"__esModule",{value:!0}),e.isometricToPoint=e.rotatePoint=e.sincos=e.radian=e.round=void 0;var r=n(37);e.round=function(t){var e=Math.pow(10,r.DECIMALS);return Math.round(t*e)/e},e.radian=function(t){return t*Math.PI/180},e.sincos=function(t){return{sin:e.round(Math.sin(t)),cos:e.round(Math.cos(t))}},e.rotatePoint=function(t,n,i){var r=Math.sqrt(Math.pow(t,2)+Math.pow(n,2)),a=Math.atan2(n,t)+e.radian(i);return{x:Math.cos(a)*r,y:Math.sin(a)*r}},e.isometricToPoint=function(t,n){var a=t.right,o=void 0===a?0:a,s=t.left,l=void 0===s?0:s,u=t.top,c=void 0===u?0:u;return n&&n.length&&i([],n).reverse().forEach((function(t){switch(t.axis){case r.AXIS.top:var n=e.rotatePoint(o,l,t.value);o=n.x,l=n.y;break;case r.AXIS.right:n=e.rotatePoint(l,c,t.value),l=n.x,c=n.y;break;case r.AXIS.left:n=e.rotatePoint(c,o,t.value),c=n.x,o=n.y}})),{x:e.round((o-l)*r.HSQRT3),y:e.round((o+l)/2-c)}}},361:function(t,e,n){var i=this&&this.__spreadArray||function(t,e){for(var n=0,i=e.length,r=t.length;n<i;n++,r++)t[r]=e[n];return t};Object.defineProperty(e,"__esModule",{value:!0}),e.getViewMatrix=e.rotationToRotationMatrix=e.sideMatrix=e.frontMatrix=e.topMatrix=e.rotateZ=e.rotateY=e.rotateX=e.multiplyMatrices=e.multiplyMatrix=void 0;var r=n(37),a=n(854);e.multiplyMatrix=function(t,e){return t.map((function(n,i){return e[0].map((function(r,a){return n.reduce((function(n,r,o){return n+t[i][o]*e[o][a]}),0)}))}))},e.multiplyMatrices=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var i=t[0],r=1;r<t.length;r++)i=e.multiplyMatrix(i,t[r]);return i},e.rotateX=function(t){var e=a.sincos(t);return[[1,0,0],[0,e.cos,-e.sin],[0,e.sin,e.cos]]},e.rotateY=function(t){var e=a.sincos(t);return[[e.cos,0,e.sin],[0,1,0],[-e.sin,0,e.cos]]},e.rotateZ=function(t){var e=a.sincos(t);return[[e.cos,-e.sin,0],[e.sin,e.cos,0],[0,0,1]]},e.topMatrix=e.multiplyMatrices(e.rotateX(r.ROT_CMA),e.rotateZ(-r.ROT_45)),e.frontMatrix=e.multiplyMatrices(e.rotateZ(-r.ROT_60),e.rotateX(r.ROT_CMA),e.rotateZ(r.ROT_45)),e.sideMatrix=e.multiplyMatrices(e.rotateZ(r.ROT_60),e.rotateX(r.ROT_CMA),e.rotateZ(-r.ROT_45)),e.rotationToRotationMatrix=function(t,n){var i=a.radian(n.value);switch(t){case r.VIEW.top:switch(n.axis){case r.AXIS.top:return e.rotateZ(i);case r.AXIS.left:return e.rotateX(-i);case r.AXIS.right:return e.rotateY(i);default:return null}case r.VIEW.front:switch(n.axis){case r.AXIS.top:return e.rotateY(i);case r.AXIS.left:return e.rotateX(i);case r.AXIS.right:return e.rotateZ(i);default:return null}case r.VIEW.side:switch(n.axis){case r.AXIS.top:return e.rotateY(i);case r.AXIS.left:return e.rotateZ(i);case r.AXIS.right:return e.rotateX(-i);default:return null}default:return null}},e.getViewMatrix=function(t,n,a){var o=[];n.forEach((function(n){var i=e.rotationToRotationMatrix(t,n);i&&o.push(i)}));var s=a?e.rotationToRotationMatrix(t,a):null;switch(s&&o.push(s),t){case r.VIEW.top:return e.multiplyMatrices.apply(void 0,i([e.topMatrix],o));case r.VIEW.front:return e.multiplyMatrices.apply(void 0,i([e.frontMatrix],o));case r.VIEW.side:return e.multiplyMatrices.apply(void 0,i([e.sideMatrix],o))}return null}},821:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hash=e.kebab=void 0,e.kebab=function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},e.hash=function(t){for(var e,n=0,i=0,r=t.length;r>=4;++i,r-=4)e=1540483477*(65535&(e=255&t.charCodeAt(i)|(255&t.charCodeAt(++i))<<8|(255&t.charCodeAt(++i))<<16|(255&t.charCodeAt(++i))<<24))+(59797*(e>>>16)<<16),n=1540483477*(65535&(e^=e>>>24))+(59797*(e>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(r){case 3:n^=(255&t.charCodeAt(i+2))<<16;case 2:n^=(255&t.charCodeAt(i+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(i)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}},228:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validAnimation=e.validTexture=e.validRotation=e.validPosition=e.validView=e.validStringByRegExp=e.undefinedOrValidNumber=e.undefinedOrValidBoolean=e.undefinedOrValidString=e.validBoolean=e.validUndefined=e.validNumberGreaterThanZero=e.validString=e.validNumber=void 0;var i=n(37);e.validNumber=function(t){return!isNaN(+(""+t))},e.validString=function(t){return t&&"string"==typeof t&&t.trim().length>0},e.validNumberGreaterThanZero=function(t){return e.validNumber(t)&&+t>0},e.validUndefined=function(t){return void 0===t},e.validBoolean=function(t){return"boolean"==typeof t},e.undefinedOrValidString=function(t){return e.validUndefined(t)||e.validString(t)},e.undefinedOrValidBoolean=function(t){return e.validUndefined(t)||e.validBoolean(t)},e.undefinedOrValidNumber=function(t){return e.validUndefined(t)||e.validNumber(t)},e.validStringByRegExp=function(t,n){return e.validUndefined(t)||e.validString(t)&&n.test(t)},e.validView=function(t){return t&&(t===i.VIEW.top||t===i.VIEW.front||t===i.VIEW.side)},e.validPosition=function(t){return t&&(e.validNumberGreaterThanZero(t.right)||e.validNumberGreaterThanZero(t.left)||e.validNumberGreaterThanZero(t.top))},e.validRotation=function(t){return t&&e.validNumber(t.value)&&(t.axis===i.AXIS.right||t.axis===i.AXIS.left||t.axis===i.AXIS.top)},e.validTexture=function(t){return t&&e.validString(t.url)&&e.undefinedOrValidString(t.size)&&e.undefinedOrValidBoolean(t.pixelated)},e.validAnimation=function(t){return t&&e.validPosition(t.position)&&e.validStringByRegExp(t.easing,i.EASING_REG_EXP)&&e.undefinedOrValidNumber(t.duration)&&e.undefinedOrValidNumber(t.repeat)&&e.undefinedOrValidBoolean(t.bounce)}}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var a=e[i]={exports:{}};return t[i].call(a.exports,a,a.exports,n),a.exports}(607)})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["isometric-css"]=e():t["isometric-css"]=e()}(this,(function(){return(()=>{"use strict";var t={158:function(t,e,n){var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var r=n(539),a=n(228),o=n(995),s=function(){function t(){this._elements=new Map,this._classes=new Map,this._keyframes=new Map,this._styles=new o.Styles}return t.prototype.hasAnimation=function(t){var e=this._elements.get(t);return!(!e||!e.keyframesName)},t.prototype.removeClasses=function(t,e){t.classList.remove(e);var n=this._classes.get(e),i=n.findIndex((function(e){return e===t}));n.splice(i,1),0===n.length&&(this._classes.delete(e),this._styles.remove(e))},t.prototype.removeKeyframes=function(t,e){var n=this._keyframes.get(e),i=n.findIndex((function(e){return e===t}));n.splice(i,1),0===n.length&&(this._keyframes.delete(e),this._styles.remove(e))},t.prototype.process=function(t,e){var n=this._elements.get(t),i=this._styles.getRuleData(e);if(i){var r={plane:e,selector:i.selector,rule:i.rule};if(n){if(n.selector===i.selector&&n.keyframesName===i.keyframesName)return;this.removeClasses(t,n.selector),n.keyframesName&&this.removeKeyframes(t,n.keyframesName)}t.classList.add(i.selector);var a=this._classes.get(i.selector);if(a?a.push(t):(this._styles.insert(i.selector,i.declaration),this._classes.set(i.selector,[t])),i.keyframesName&&i.keyframesDeclaration){var o=this._keyframes.get(i.keyframesName);o?o.push(t):(this._styles.insertKeyframes(i.keyframesName,i.keyframesDeclaration),this._keyframes.set(i.keyframesName,[t])),r.keyframes=i.keyframes,r.keyframesName=i.keyframesName}this._elements.set(t,r)}},t.prototype.addElement=function(t){var e=r.getPlaneFromElement(t);this.process(t,e)},t.prototype.removeElement=function(t){r.resetElementIsometricData(t);var e=this._elements.get(t);e&&(this._elements.delete(t),this.removeClasses(t,e.selector),e.keyframesName&&this.removeKeyframes(t,e.keyframesName))},t.prototype.setElementView=function(t,e){if(a.validView(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{view:e}):{view:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementPosition=function(t,e){if(a.validPosition(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{position:i(i({},n.plane.position),e)}):{position:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementRotation=function(t,e){if(a.validRotation(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{rotation:e}):{rotation:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementTexture=function(t,e){if(a.validTexture(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{texture:i(i({},n.plane.texture),e)}):{texture:e,parentRotations:r.getParentRotations(t)})}},t.prototype.setElementAnimation=function(t,e){if(a.validAnimation(e)){var n=this._elements.get(t);this.process(t,n?i(i({},n.plane),{animation:n.plane.animation?i(i({},n.plane.animation),e):e}):{animation:e,parentRotations:r.getParentRotations(t)})}},t.prototype.resetAnimation=function(t){if(this.hasAnimation(t)){var e=t.className;t.className="",t.offsetWidth,t.className=e}},t.prototype.pauseAnimation=function(t){this.hasAnimation(t)&&(t.dataset.animationRunning="false")},t.prototype.resumeAnimation=function(t){this.hasAnimation(t)&&(t.dataset.animationRunning="true")},t}();e.default=new s},995:function(t,e,n){var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Styles=void 0;var r=n(821),a=n(37),o=n(821),s=n(854),l=n(361),u=function(){function t(){this._globalStyle=null,this._style=null,this.scale=s.round(a.SCALE),this.P50="50%",this.transformBefore="translate(-"+this.P50+", -"+this.P50+")",this.tranformAfterTop="translate(-"+this.P50+", "+this.P50+")",this.transformAfterFront="translate(-"+this.P50+", -"+this.P50+")",this.transformAfterSide="translate("+this.P50+", -"+this.P50+")",this.baseDeclarations={position:"absolute"},this.transformOriginDeclarations={transformOrigin:this.P50+" "+this.P50,MsTransformOrigin:this.P50+" "+this.P50,WebkitTransformOrigin:this.P50+" "+this.P50}}return Object.defineProperty(t.prototype,"sheet",{get:function(){return this._style?this._style.sheet:null},enumerable:!1,configurable:!0}),t.prototype.getTransform=function(t,e,n){var i=l.getViewMatrix(t,e,n);if(!i)return null;var r="matrix("+s.round(i[0][0])+","+s.round(i[1][0])+","+s.round(i[0][1])+","+s.round(i[1][1])+",0,0)",o=this.transformBefore+" "+r+" scale("+this.scale+")";switch(t){case a.VIEW.top:return o+" "+this.tranformAfterTop;case a.VIEW.front:return o+" "+this.transformAfterFront;case a.VIEW.side:return o+" "+this.transformAfterSide}},t.prototype.insertGlobalStyles=function(){this._globalStyle.sheet.insertRule('[data-animation][data-animation-running="false"] {\n animation-play-state: paused;\n }')},t.prototype.init=function(){var t=document.getElementsByTagName("head")[0];this._globalStyle=document.createElement("style"),this._style=document.createElement("style"),this._globalStyle.dataset.isometricGlobal="",this._style.dataset.isometric="",t.appendChild(this._globalStyle),t.appendChild(this._style),this.insertGlobalStyles()},t.prototype.getKeyframes=function(t){if(t.animation){var e=t.position||{right:0,left:0,top:0},n=s.isometricToPoint(e,t.parentRotations),r=s.isometricToPoint(i(i({},e),t.animation.position),t.parentRotations);return{from:{left:n.x+"px",top:n.y+"px"},to:{left:r.x+"px",top:r.y+"px"}}}return null},t.prototype.getRule=function(t,e){var n=this.getTransform(t.view,t.parentRotations,t.rotation),r=n?i(i(i({},this.baseDeclarations),this.transformOriginDeclarations),{transform:n,MsTransform:n,WebkitTransform:n}):t.position||t.texture||t.animation&&e?i({},this.baseDeclarations):{};if(t.position){var a=s.isometricToPoint(t.position,t.parentRotations);r.left=a.x+"px",r.top=a.y+"px"}return t.texture&&(r.backgroundImage='url("'+t.texture.url+'")',r.backgroundSize=t.texture.size||"cover",t.texture.pixelated&&(r.MsInterpolationMode="nearest-neighbor",r.imageRendering="pixelated",r.fallbacks=[{imageRendering:"crisp-edges"}])),t.animation&&e&&(r.animationName=e,r.animationDuration=t.animation.duration?t.animation.duration+"ms":"1000ms",r.animationTimingFunction=t.animation.easing||"linear",r.animationIterationCount=t.animation.repeat?t.animation.bounce?""+2*t.animation.repeat:""+t.animation.repeat:"infinite",r.animationDirection=t.animation.bounce?"alternate":"normal",r.animationFillMode="both"),r},t.prototype.getDeclarationString=function(t){var e=this;return Object.entries(t).reduce((function(t,n){return Array.isArray(n[1])?""+t+n[1].map((function(t){return e.getDeclarationString(t)})).join("\n"):"object"==typeof n[1]?t+"\n"+o.kebab(n[0])+" {"+e.getDeclarationString(n[1])+"\n}":t+"\n "+o.kebab(n[0])+": "+n[1]+";"}),"")},t.prototype.getSelector=function(t){return a.NAMESPACE+"-"+r.hash(t)},t.prototype.getRuleData=function(t){var e=this.getKeyframes(t),n=e?this.getDeclarationString(e):null,i=n?this.getSelector(n):null,r=this.getRule(t,i);if(Object.keys(r).length){var a=this.getDeclarationString(r),o={rule:r,declaration:a,selector:this.getSelector(a)};return e&&(o.keyframes=e,o.keyframesDeclaration=n,o.keyframesName=i),o}return null},t.prototype.insert=function(t,e){this.sheet||this.init(),this.sheet.insertRule("."+t+" {\n"+e+"\n}")},t.prototype.insertKeyframes=function(t,e){this.sheet.insertRule("@keyframes "+t+" {\n"+e+"\n}")},t.prototype.remove=function(t){var e=this;Array.prototype.some.call(this.sheet.cssRules,(function(n,i){return("name"in n&&n.name===t||"selectorText"in n&&n.selectorText.slice(1)===t)&&(e.sheet.deleteRule(i),!0)}))},t}();e.Styles=u},37:(t,e)=>{var n,i;Object.defineProperty(e,"__esModule",{value:!0}),e.TYPE_UNDEFINED=e.AXIS=e.VIEW=e.EASING_REG_EXP=e.PROPS_REG_EXP=e.ROT_CMA=e.ROT_45=e.ROT_60=e.SCALE=e.HSQRT3=e.DECIMALS=e.NAMESPACE=void 0,e.NAMESPACE="isometric",e.DECIMALS=6,e.HSQRT3=+(Math.sqrt(3)/2).toFixed(e.DECIMALS),e.SCALE=Math.sqrt(1.5),e.ROT_60=Math.PI/3,e.ROT_45=Math.PI/4,e.ROT_CMA=Math.atan(Math.SQRT2),e.PROPS_REG_EXP=/(?: |,|^)((?:right|left|top)+)\s*:\s*((?:\d+)?\.\d+|\d+)(?= |,|$)/g,e.EASING_REG_EXP=/^((ease(-in|-out|-in-out)?)|linear|(step(-start|-end)))$/,(i=e.VIEW||(e.VIEW={})).top="top",i.front="front",i.side="side",(n=e.AXIS||(e.AXIS={})).right="right",n.left="left",n.top="top",e.TYPE_UNDEFINED="undefined"},607:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IsometricCSS=void 0;var i=n(37),r=n(158);e.IsometricCSS={processDOM:function(){Array.prototype.forEach.call(document.querySelectorAll("."+i.NAMESPACE),(function(t){r.default.addElement(t)}))},processElement:function(t){r.default.addElement(t)},resetElement:function(t){r.default.removeElement(t)},setView:function(t,e){r.default.setElementView(t,e)},setRotation:function(t,e){r.default.setElementRotation(t,e)},setPosition:function(t,e){r.default.setElementPosition(t,e)},setTexture:function(t,e){r.default.setElementTexture(t,e)},setAnimation:function(t,e){r.default.setElementAnimation(t,e)},resetAnimation:function(t){r.default.resetAnimation(t)},pauseAnimation:function(t){r.default.pauseAnimation(t)},resumeAnimation:function(t){r.default.resumeAnimation(t)}},typeof window!==i.TYPE_UNDEFINED&&typeof document!==i.TYPE_UNDEFINED&&(window.IsometricCSS=e.IsometricCSS,window.addEventListener("DOMContentLoaded",(function(){e.IsometricCSS.processDOM()})))},539:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resetElementIsometricData=e.getPlaneFromElement=e.getAnimation=e.getParentRotations=void 0;var i=n(37),r=n(228);e.getParentRotations=function(t){for(var e=[];t.parentElement&&t.parentElement!==document.documentElement;){var n=t.parentElement;n.classList.contains(i.NAMESPACE)&&!n.dataset.view&&n.dataset.rotationAxis&&e.push({axis:n.dataset.rotationAxis,value:+(n.dataset.rotationValue||0)}),t=t.parentElement}return e},e.getAnimation=function(t,e,n,a,o){if(t){for(var s={},l=void 0;null!==(l=i.PROPS_REG_EXP.exec(t));){var u=l[1],c=+l[2];s[u]=c}if(Object.keys(s).length){var f={position:s,repeat:a&&+a>0?+a:0,bounce:o&&"true"===o.trim()};return n&&i.EASING_REG_EXP.test(n.trim())&&(f.easing=n.trim()),r.validNumber(e)&&(f.duration=+e),f}}return null},e.getPlaneFromElement=function(t){var n=t.dataset,i=n.view?n.view:null,r=+(n.right||0),a=+(n.left||0),o=+(n.top||0),s=n.rotationAxis?n.rotationAxis:null,l=+(n.rotationValue||0),u=n.texture,c=n.textureSize||"cover",f="true"===n.texturePixelated,m=e.getParentRotations(t),d=e.getAnimation(n.animation,n.animationDuration,n.animationEasing,n.animationRepeat,n.animationBounce),p={parentRotations:m};return i&&(p.view=i),(r||a||o)&&(p.position={right:r,left:a,top:o}),s&&l&&(p.rotation={axis:s,value:l}),u&&(p.texture={url:u,size:c,pixelated:f}),d&&(p.animation=d),p},e.resetElementIsometricData=function(t){t.classList.remove(i.NAMESPACE),function(t,e){["view","right","left","top","rotationAxis","rotationValue","texture","textureSize","texturePixelated","animation","animationDuration","animationEasing","animationRepeat","animationBounce","animationRunning"].forEach((function(e){t.dataset[e]&&delete t.dataset[e]}))}(t)}},854:function(t,e,n){var i=this&&this.__spreadArray||function(t,e){for(var n=0,i=e.length,r=t.length;n<i;n++,r++)t[r]=e[n];return t};Object.defineProperty(e,"__esModule",{value:!0}),e.isometricToPoint=e.rotatePoint=e.sincos=e.radian=e.round=void 0;var r=n(37);e.round=function(t){var e=Math.pow(10,r.DECIMALS);return Math.round(t*e)/e},e.radian=function(t){return t*Math.PI/180},e.sincos=function(t){return{sin:e.round(Math.sin(t)),cos:e.round(Math.cos(t))}},e.rotatePoint=function(t,n,i){var r=Math.sqrt(Math.pow(t,2)+Math.pow(n,2)),a=Math.atan2(n,t)+e.radian(i);return{x:Math.cos(a)*r,y:Math.sin(a)*r}},e.isometricToPoint=function(t,n){var a=t.right,o=void 0===a?0:a,s=t.left,l=void 0===s?0:s,u=t.top,c=void 0===u?0:u;return n&&n.length&&i([],n).reverse().forEach((function(t){switch(t.axis){case r.AXIS.top:var n=e.rotatePoint(o,l,t.value);o=n.x,l=n.y;break;case r.AXIS.right:n=e.rotatePoint(l,c,t.value),l=n.x,c=n.y;break;case r.AXIS.left:n=e.rotatePoint(c,o,t.value),c=n.x,o=n.y}})),{x:e.round((o-l)*r.HSQRT3),y:e.round((o+l)/2-c)}}},361:function(t,e,n){var i=this&&this.__spreadArray||function(t,e){for(var n=0,i=e.length,r=t.length;n<i;n++,r++)t[r]=e[n];return t};Object.defineProperty(e,"__esModule",{value:!0}),e.getViewMatrix=e.rotationToRotationMatrix=e.sideMatrix=e.frontMatrix=e.topMatrix=e.rotateZ=e.rotateY=e.rotateX=e.multiplyMatrices=e.multiplyMatrix=void 0;var r=n(37),a=n(854);e.multiplyMatrix=function(t,e){return t.map((function(n,i){return e[0].map((function(r,a){return n.reduce((function(n,r,o){return n+t[i][o]*e[o][a]}),0)}))}))},e.multiplyMatrices=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var i=t[0],r=1;r<t.length;r++)i=e.multiplyMatrix(i,t[r]);return i},e.rotateX=function(t){var e=a.sincos(t);return[[1,0,0],[0,e.cos,-e.sin],[0,e.sin,e.cos]]},e.rotateY=function(t){var e=a.sincos(t);return[[e.cos,0,e.sin],[0,1,0],[-e.sin,0,e.cos]]},e.rotateZ=function(t){var e=a.sincos(t);return[[e.cos,-e.sin,0],[e.sin,e.cos,0],[0,0,1]]},e.topMatrix=e.multiplyMatrices(e.rotateX(r.ROT_CMA),e.rotateZ(-r.ROT_45)),e.frontMatrix=e.multiplyMatrices(e.rotateZ(-r.ROT_60),e.rotateX(r.ROT_CMA),e.rotateZ(r.ROT_45)),e.sideMatrix=e.multiplyMatrices(e.rotateZ(r.ROT_60),e.rotateX(r.ROT_CMA),e.rotateZ(-r.ROT_45)),e.rotationToRotationMatrix=function(t,n){var i=a.radian(n.value);switch(t){case r.VIEW.top:switch(n.axis){case r.AXIS.top:return e.rotateZ(i);case r.AXIS.left:return e.rotateX(-i);case r.AXIS.right:return e.rotateY(i);default:return null}case r.VIEW.front:switch(n.axis){case r.AXIS.top:return e.rotateY(i);case r.AXIS.left:return e.rotateX(i);case r.AXIS.right:return e.rotateZ(i);default:return null}case r.VIEW.side:switch(n.axis){case r.AXIS.top:return e.rotateY(i);case r.AXIS.left:return e.rotateZ(i);case r.AXIS.right:return e.rotateX(-i);default:return null}default:return null}},e.getViewMatrix=function(t,n,a){var o=[];n.forEach((function(n){var i=e.rotationToRotationMatrix(t,n);i&&o.push(i)}));var s=a?e.rotationToRotationMatrix(t,a):null;switch(s&&o.push(s),t){case r.VIEW.top:return e.multiplyMatrices.apply(void 0,i([e.topMatrix],o));case r.VIEW.front:return e.multiplyMatrices.apply(void 0,i([e.frontMatrix],o));case r.VIEW.side:return e.multiplyMatrices.apply(void 0,i([e.sideMatrix],o))}return null}},821:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hash=e.kebab=void 0,e.kebab=function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},e.hash=function(t){for(var e,n=0,i=0,r=t.length;r>=4;++i,r-=4)e=1540483477*(65535&(e=255&t.charCodeAt(i)|(255&t.charCodeAt(++i))<<8|(255&t.charCodeAt(++i))<<16|(255&t.charCodeAt(++i))<<24))+(59797*(e>>>16)<<16),n=1540483477*(65535&(e^=e>>>24))+(59797*(e>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(r){case 3:n^=(255&t.charCodeAt(i+2))<<16;case 2:n^=(255&t.charCodeAt(i+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(i)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}},228:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validAnimation=e.validTexture=e.validRotation=e.validPosition=e.validView=e.validStringByRegExp=e.undefinedOrValidNumber=e.undefinedOrValidBoolean=e.undefinedOrValidString=e.validBoolean=e.validUndefined=e.validNumberGreaterThanZero=e.validString=e.validNumber=void 0;var i=n(37);e.validNumber=function(t){return!isNaN(+(""+t))},e.validString=function(t){return t&&"string"==typeof t&&t.trim().length>0},e.validNumberGreaterThanZero=function(t){return e.validNumber(t)&&+t>0},e.validUndefined=function(t){return void 0===t},e.validBoolean=function(t){return"boolean"==typeof t},e.undefinedOrValidString=function(t){return e.validUndefined(t)||e.validString(t)},e.undefinedOrValidBoolean=function(t){return e.validUndefined(t)||e.validBoolean(t)},e.undefinedOrValidNumber=function(t){return e.validUndefined(t)||e.validNumber(t)},e.validStringByRegExp=function(t,n){return e.validUndefined(t)||e.validString(t)&&n.test(t)},e.validView=function(t){return t&&(t===i.VIEW.top||t===i.VIEW.front||t===i.VIEW.side)},e.validPosition=function(t){return t&&(e.validNumberGreaterThanZero(t.right)||e.validNumberGreaterThanZero(t.left)||e.validNumberGreaterThanZero(t.top))},e.validRotation=function(t){return t&&e.validNumber(t.value)&&(t.axis===i.AXIS.right||t.axis===i.AXIS.left||t.axis===i.AXIS.top)},e.validTexture=function(t){return t&&e.validString(t.url)&&e.undefinedOrValidString(t.size)&&e.undefinedOrValidBoolean(t.pixelated)},e.validAnimation=function(t){return t&&e.validPosition(t.position)&&e.validStringByRegExp(t.easing,i.EASING_REG_EXP)&&e.undefinedOrValidNumber(t.duration)&&e.undefinedOrValidNumber(t.repeat)&&e.undefinedOrValidBoolean(t.bounce)}}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var a=e[i]={exports:{}};return t[i].call(a.exports,a,a.exports,n),a.exports}(607)})()})); |
{ | ||
"name": "isometric-css", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A lightweight JavaScript library to build isometric projections through declarative HTML attributes", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -15,3 +15,3 @@ <p align="center"> | ||
## Documentation | ||
## Demo and Documentation | ||
@@ -18,0 +18,0 @@ https://elchininet.github.io/isometric-css/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39052