isometric-css
Advanced tools
Comparing version 2.2.3 to 2.2.4
@@ -1,3 +0,35 @@ | ||
import { View, IsometricPosition, Rotation, Texture, Animation } from './@types'; | ||
export declare const IsometricCSS: { | ||
declare enum VIEW { | ||
top = "top", | ||
front = "front", | ||
side = "side" | ||
} | ||
declare enum AXIS { | ||
right = "right", | ||
left = "left", | ||
top = "top" | ||
} | ||
type View = keyof typeof VIEW; | ||
type Axis = keyof typeof AXIS; | ||
interface IsometricPosition { | ||
right?: number; | ||
left?: number; | ||
top?: number; | ||
} | ||
interface Rotation { | ||
axis: Axis; | ||
value: number; | ||
} | ||
interface Texture { | ||
url: string; | ||
size?: string; | ||
pixelated?: boolean; | ||
} | ||
interface Animation { | ||
position: IsometricPosition; | ||
duration?: number; | ||
easing?: string; | ||
repeat?: number; | ||
bounce?: boolean; | ||
} | ||
declare const IsometricCSS: { | ||
processDOM(): void; | ||
@@ -20,1 +52,2 @@ processElement(element: HTMLElement): void; | ||
} | ||
export { IsometricCSS }; |
@@ -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||{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+)(?= |,|$)/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.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.validNumberNonZero=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.validNumberNonZero=function(t){return e.validNumber(t)&&0!=+t},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.validNumberNonZero(t.right)||e.validNumberNonZero(t.left)||e.validNumberNonZero(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&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["isometric-css"]={})}(this,(function(t){"use strict";var e,n,a="isometric",i=+(Math.sqrt(3)/2).toFixed(6),o=Math.sqrt(1.5),r=Math.PI/3,s=Math.PI/4,c=Math.atan(Math.SQRT2),u=/(?: |,|^)(right|left|top)\s*:\s*(-?\d*?\.?\d+)(?= |,|$)/g,l=/^((ease(-in|-out|-in-out)?)|linear|(step(-start|-end)))$/;!function(t){t.top="top",t.front="front",t.side="side"}(e||(e={})),function(t){t.right="right",t.left="left",t.top="top"}(n||(n={}));var f="undefined",m=function(){return m=Object.assign||function(t){for(var e,n=1,a=arguments.length;n<a;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},m.apply(this,arguments)};function p(t,e,n){if(n||2===arguments.length)for(var a,i=0,o=e.length;i<o;i++)!a&&i in e||(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return t.concat(a||Array.prototype.slice.call(e))}var h=function(t){return!isNaN(+"".concat(t))},y=function(t){return t&&"string"==typeof t&&t.trim().length>0},d=function(t){return h(t)&&0!=+t},g=function(t){return void 0===t},v=function(t){return g(t)||function(t){return"boolean"==typeof t}(t)},x=function(t){return g(t)||h(t)},A=function(t){return t&&(d(t.right)||d(t.left)||d(t.top))},_=function(t){return t&&y(t.url)&&(e=t.size,g(e)||y(e))&&v(t.pixelated);var e},b=function(t){return t&&A(t.position)&&(e=t.easing,n=l,g(e)||y(e)&&n.test(e))&&x(t.duration)&&x(t.repeat)&&v(t.bounce);var e,n},k=function(t){for(var e=[];t.parentElement&&t.parentElement!==document.documentElement;){var n=t.parentElement;!n.dataset.view&&n.dataset.rotationAxis&&e.push({axis:n.dataset.rotationAxis,value:+(n.dataset.rotationValue||0)}),t=t.parentElement}return e},w=function(t){var e=t.dataset,n=e.view?e.view:null,a=+(e.right||0),i=+(e.left||0),o=+(e.top||0),r=e.rotationAxis?e.rotationAxis:null,s=+(e.rotationValue||0),c=e.texture,f=e.textureSize||"cover",m="true"===e.texturePixelated,p=k(t),y=function(t,e,n,a,i){if(t){for(var o={},r=void 0;null!==(r=u.exec(t));){var s=r[1],c=+r[2];o[s]=c}if(Object.keys(o).length){var f={position:o,repeat:a&&+a>0?+a:0,bounce:i&&"true"===i.trim()};return n&&l.test(n.trim())&&(f.easing=n.trim()),h(e)&&(f.duration=+e),f}}return null}(e.animation,e.animationDuration,e.animationEasing,e.animationRepeat,e.animationBounce),d={parentRotations:p};return n&&(d.view=n),(a||i||o)&&(d.position={right:a,left:i,top:o}),r&&s&&(d.rotation={axis:r,value:s}),c&&(d.texture={url:c,size:f,pixelated:m}),y&&(d.animation=y),d},E=function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},R=function(t){var e=Math.pow(10,6);return Math.round(t*e)/e},M=function(t){return t*Math.PI/180},S=function(t){return{sin:R(Math.sin(t)),cos:R(Math.cos(t))}},P=function(t,e,n){var a=Math.sqrt(Math.pow(t,2)+Math.pow(e,2)),i=Math.atan2(e,t)+M(n);return{x:Math.cos(i)*a,y:Math.sin(i)*a}},D=function(t,e){var a=t.right,o=void 0===a?0:a,r=t.left,s=void 0===r?0:r,c=t.top,u=void 0===c?0:c;e&&e.length&&p([],e,!0).reverse().forEach((function(t){switch(t.axis){case n.top:var e=P(o,s,t.value);o=e.x,s=e.y;break;case n.right:e=P(s,u,t.value);s=e.x,u=e.y;break;case n.left:e=P(u,o,t.value);u=e.x,o=e.y}}));return{x:R((o-s)*i),y:R((o+s)/2-u)}},N=function(t,e){return t.map((function(n,a){return e[0].map((function(i,o){return n.reduce((function(n,i,r){return n+t[a][r]*e[r][o]}),0)}))}))},T=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=t[0],a=1;a<t.length;a++)n=N(n,t[a]);return n},C=function(t){var e=S(t);return[[1,0,0],[0,e.cos,-e.sin],[0,e.sin,e.cos]]},O=function(t){var e=S(t);return[[e.cos,0,e.sin],[0,1,0],[-e.sin,0,e.cos]]},j=function(t){var e=S(t);return[[e.cos,-e.sin,0],[e.sin,e.cos,0],[0,0,1]]},I=T(C(c),j(-s)),K=T(j(-r),C(c),j(s)),z=T(j(r),C(c),j(-s)),L=function(t,a){var i=M(a.value);switch(t){case e.top:switch(a.axis){case n.top:return j(i);case n.left:return C(-i);case n.right:return O(i);default:return null}case e.front:switch(a.axis){case n.top:return O(i);case n.left:return C(i);case n.right:return j(i);default:return null}case e.side:switch(a.axis){case n.top:return O(i);case n.left:return j(i);case n.right:return C(-i);default:return null}default:return null}},V=function(){function t(){this._globalStyle=null,this._style=null,this.scale=R(o),this.P50="50%",this.transformBefore="translate(-".concat(this.P50,", -").concat(this.P50,")"),this.tranformAfterTop="translate(-".concat(this.P50,", ").concat(this.P50,")"),this.transformAfterFront="translate(-".concat(this.P50,", -").concat(this.P50,")"),this.transformAfterSide="translate(".concat(this.P50,", -").concat(this.P50,")"),this.baseDeclarations={position:"absolute"},this.transformOriginDeclarations={transformOrigin:"".concat(this.P50," ").concat(this.P50),MsTransformOrigin:"".concat(this.P50," ").concat(this.P50),WebkitTransformOrigin:"".concat(this.P50," ").concat(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,n,a){var i=function(t,n,a){var i=[];n.forEach((function(e){var n=L(t,e);n&&i.push(n)}));var o=a?L(t,a):null;switch(o&&i.push(o),t){case e.top:return T.apply(void 0,p([I],i,!1));case e.front:return T.apply(void 0,p([K],i,!1));case e.side:return T.apply(void 0,p([z],i,!1))}return null}(t,n,a);if(!i)return null;var o=R(i[0][0]),r=R(i[1][0]),s=R(i[0][1]),c=R(i[1][1]),u="matrix(".concat(o,",").concat(r,",").concat(s,",").concat(c,",0,0)"),l="".concat(this.transformBefore," ").concat(u," scale(").concat(this.scale,")");switch(t){case e.top:return"".concat(l," ").concat(this.tranformAfterTop);case e.front:return"".concat(l," ").concat(this.transformAfterFront);case e.side:return"".concat(l," ").concat(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=D(e,t.parentRotations),a=D(m(m({},e),t.animation.position),t.parentRotations);return{from:{left:"".concat(n.x,"px"),top:"".concat(n.y,"px")},to:{left:"".concat(a.x,"px"),top:"".concat(a.y,"px")}}}return null},t.prototype.getRule=function(t,e){var n=this.getTransform(t.view,t.parentRotations,t.rotation),a=n?m(m(m({},this.baseDeclarations),this.transformOriginDeclarations),{transform:n,MsTransform:n,WebkitTransform:n}):t.position||t.texture||t.animation&&e?m({},this.baseDeclarations):{};if(t.position){var i=D(t.position,t.parentRotations);a.left="".concat(i.x,"px"),a.top="".concat(i.y,"px")}return t.texture&&(a.backgroundImage='url("'.concat(t.texture.url,'")'),a.backgroundSize=t.texture.size||"cover",t.texture.pixelated&&(a.MsInterpolationMode="nearest-neighbor",a.imageRendering="pixelated",a.fallbacks=[{imageRendering:"crisp-edges"}])),t.animation&&e&&(a.animationName=e,a.animationDuration=t.animation.duration?"".concat(t.animation.duration,"ms"):"1000ms",a.animationTimingFunction=t.animation.easing||"linear",a.animationIterationCount=t.animation.repeat?t.animation.bounce?"".concat(2*t.animation.repeat):"".concat(t.animation.repeat):"infinite",a.animationDirection=t.animation.bounce?"alternate":"normal",a.animationFillMode="both"),a},t.prototype.getDeclarationString=function(t){var e=this;return Object.entries(t).reduce((function(t,n){if(Array.isArray(n[1])){var a=n[1].map((function(t){return e.getDeclarationString(t)})).join("\n");return"".concat(t).concat(a)}return"object"==typeof n[1]?"".concat(t,"\n").concat(E(n[0])," {").concat(e.getDeclarationString(n[1]),"\n}"):"".concat(t,"\n ").concat(E(n[0]),": ").concat(n[1],";")}),"")},t.prototype.getSelector=function(t){return"".concat(a,"-").concat(function(t){for(var e,n=0,a=0,i=t.length;i>=4;++a,i-=4)e=1540483477*(65535&(e=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<24))+(59797*(e>>>16)<<16),n=1540483477*(65535&(e^=e>>>24))+(59797*(e>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&t.charCodeAt(a+2))<<16;case 2:n^=(255&t.charCodeAt(a+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(a)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(t))},t.prototype.getRuleData=function(t){var e=this.getKeyframes(t),n=e?this.getDeclarationString(e):null,a=n?this.getSelector(n):null,i=this.getRule(t,a);if(Object.keys(i).length){var o=this.getDeclarationString(i),r={rule:i,declaration:o,selector:this.getSelector(o)};return e&&(r.keyframes=e,r.keyframesDeclaration=n,r.keyframesName=a),r}return null},t.prototype.insert=function(t,e){this.sheet||this.init(),this.sheet.insertRule(".".concat(t," {\n").concat(e,"\n}"))},t.prototype.insertKeyframes=function(t,e){this.sheet.insertRule("@keyframes ".concat(t," {\n").concat(e,"\n}"))},t.prototype.remove=function(t){var e=this;Array.prototype.some.call(this.sheet.cssRules,(function(n,a){return("name"in n&&n.name===t||"selectorText"in n&&n.selectorText.slice(1)===t)&&(e.sheet.deleteRule(a),!0)}))},t}(),B=new(function(){function t(){this._elements=new Map,this._classes=new Map,this._keyframes=new Map,this._styles=new V}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),a=n.findIndex((function(e){return e===t}));n.splice(a,1),0===n.length&&(this._classes.delete(e),this._styles.remove(e))},t.prototype.removeKeyframes=function(t,e){var n=this._keyframes.get(e),a=n.findIndex((function(e){return e===t}));n.splice(a,1),0===n.length&&(this._keyframes.delete(e),this._styles.remove(e))},t.prototype.process=function(t,e){var n=this._elements.get(t),a=this._styles.getRuleData(e);if(a){var i={plane:e,selector:a.selector,rule:a.rule};if(n){if(n.selector===a.selector&&n.keyframesName===a.keyframesName)return;this.removeClasses(t,n.selector),n.keyframesName&&this.removeKeyframes(t,n.keyframesName)}t.classList.add(a.selector);var o=this._classes.get(a.selector);if(o?o.push(t):(this._styles.insert(a.selector,a.declaration),this._classes.set(a.selector,[t])),a.keyframesName&&a.keyframesDeclaration){var r=this._keyframes.get(a.keyframesName);r?r.push(t):(this._styles.insertKeyframes(a.keyframesName,a.keyframesDeclaration),this._keyframes.set(a.keyframesName,[t])),i.keyframes=a.keyframes,i.keyframesName=a.keyframesName}this._elements.set(t,i)}},t.prototype.addElement=function(t){var e=w(t);this.process(t,e)},t.prototype.removeElement=function(t){!function(t){t.classList.remove(a),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)}(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,n){if(function(t){return t&&(t===e.top||t===e.front||t===e.side)}(n)){var a=this._elements.get(t);this.process(t,a?m(m({},a.plane),{view:n}):{view:n,parentRotations:k(t)})}},t.prototype.setElementPosition=function(t,e){if(A(e)){var n=this._elements.get(t);this.process(t,n?m(m({},n.plane),{position:m(m({},n.plane.position),e)}):{position:e,parentRotations:k(t)})}},t.prototype.setElementRotation=function(t,e){if(function(t){return t&&h(t.value)&&(t.axis===n.right||t.axis===n.left||t.axis===n.top)}(e)){var a=this._elements.get(t);this.process(t,a?m(m({},a.plane),{rotation:e}):{rotation:e,parentRotations:k(t)})}},t.prototype.setElementTexture=function(t,e){if(_(e)){var n=this._elements.get(t);this.process(t,n?m(m({},n.plane),{texture:m(m({},n.plane.texture),e)}):{texture:e,parentRotations:k(t)})}},t.prototype.setElementAnimation=function(t,e){if(b(e)){var n=this._elements.get(t);this.process(t,n?m(m({},n.plane),{animation:n.plane.animation?m(m({},n.plane.animation),e):e}):{animation:e,parentRotations:k(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}()),F={processDOM:function(){Array.prototype.forEach.call(document.querySelectorAll(".".concat(a)),(function(t){B.addElement(t)}))},processElement:function(t){B.addElement(t)},resetElement:function(t){B.removeElement(t)},setView:function(t,e){B.setElementView(t,e)},setRotation:function(t,e){B.setElementRotation(t,e)},setPosition:function(t,e){B.setElementPosition(t,e)},setTexture:function(t,e){B.setElementTexture(t,e)},setAnimation:function(t,e){B.setElementAnimation(t,e)},resetAnimation:function(t){B.resetAnimation(t)},pauseAnimation:function(t){B.pauseAnimation(t)},resumeAnimation:function(t){B.resumeAnimation(t)}};typeof window!==f&&typeof document!==f&&(window.IsometricCSS=F,window.addEventListener("DOMContentLoaded",(function(){F.processDOM()}))),t.IsometricCSS=F,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "isometric-css", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "A lightweight JavaScript library to build isometric projections through declarative HTML attributes", | ||
@@ -23,9 +23,4 @@ "keywords": [ | ||
"files": [ | ||
"@types/**/*", | ||
"constants/**/*", | ||
"dom/**/*", | ||
"utilities/**/*", | ||
"index.d.ts", | ||
"index.js", | ||
"index.js.LICENSE.txt" | ||
"index.js" | ||
], | ||
@@ -40,8 +35,7 @@ "repository": { | ||
"scripts": { | ||
"build": "webpack && tscpaths -p tsconfig.json -s ./src -o ./dist", | ||
"copy": "cp -r ./dist/. ./", | ||
"build": "rollup --config rollup.config.js", | ||
"lint": "eslint src/**/*.ts", | ||
"test": "jest --verbose", | ||
"prepare": "yarn build && yarn copy", | ||
"prepublishOnly": "npm run lint", | ||
"prepare": "yarn build", | ||
"prepublishOnly": "yarn lint && yarn test", | ||
"version": "git add .", | ||
@@ -51,17 +45,16 @@ "postversion": "git push && git push --tags" | ||
"devDependencies": { | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^15.6.1", | ||
"@typescript-eslint/eslint-plugin": "^4.25.0", | ||
"@typescript-eslint/parser": "^4.25.0", | ||
"clean-webpack-plugin": "^3.0.0", | ||
"coveralls": "^3.1.0", | ||
"eslint": "^7.27.0", | ||
"jest": "^27.0.1", | ||
"ts-jest": "^27.0.1", | ||
"ts-loader": "^9.2.2", | ||
"tscpaths": "^0.0.9", | ||
"typescript": "^4.3.2", | ||
"webpack": "^5.37.1", | ||
"webpack-cli": "^4.7.0" | ||
"@types/jest": "^29.0.3", | ||
"@types/node": "^18.7.18", | ||
"@typescript-eslint/eslint-plugin": "^5.37.0", | ||
"@typescript-eslint/parser": "^5.37.0", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^8.23.1", | ||
"jest": "^29.0.3", | ||
"jest-environment-jsdom": "^29.0.3", | ||
"rollup": "^2.79.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-ts": "^3.0.2", | ||
"ts-jest": "^29.0.1", | ||
"typescript": "^4.8.3" | ||
} | ||
} |
@@ -9,3 +9,3 @@ <p align="center"> | ||
[![Build Status](https://travis-ci.com/elchininet/isometric-css.svg?branch=master)](https://travis-ci.com/elchininet/isometric-css) [![Coverage Status](https://coveralls.io/repos/github/elchininet/isometric-css/badge.svg?branch=master)](https://coveralls.io/github/elchininet/isometric-css?branch=master) [![npm version](https://badge.fury.io/js/isometric-css.svg)](https://badge.fury.io/js/isometric-css) | ||
[![Build Status](https://travis-ci.com/elchininet/isometric-css.svg?branch=master)](https://app.travis-ci.com/elchininet/isometric-css) [![Coverage Status](https://coveralls.io/repos/github/elchininet/isometric-css/badge.svg?branch=master)](https://coveralls.io/github/elchininet/isometric-css?branch=master) [![npm version](https://badge.fury.io/js/isometric-css.svg)](https://badge.fury.io/js/isometric-css) | ||
@@ -12,0 +12,0 @@ ## 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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
13
29844
5
105
1