1/*! 2 * @pixelunion/animations v0.1.0 3 * (c) 2019 Pixel Union 4 * Released under the UNLICENSED license. 5 */function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};
5i%2?ownKeys(source,!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(source).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function raf(){return new Promise(function(resolve){window.requestAnimationFrame(resolve)})}var Animation=(function(){function Animation2(options){_classCallCheck(this,Animation2),this._el=options.el,this.cancelRunning=null,this._state=options.state||"initial",this.initialState=this._state,this.stateAttribute=options.stateAttribute||"data-animation-state",this.stateChangeAttribute=options.stateChangeAttribute||"data-animation",this.endEvent=options.endEvent||"transitionend",this.hold=!!options.hold,this.onStart=options.onStart||function(){},this.activeEventHandler=null}return _createClass(Animation2,[{key:"isState",value:function(state){return state===this._state}},{key:"animateTo",value:function(state){var _this=this,options=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},from=this._el.dataset[this.stateAttribute]||this._state,to=state||this.initialState,force=options.force,hold="hold"in options?options.hold:this.hold;return new Promise(function(resolve){if(_this.cancelRunning&&_this.cancelRunning(),from===to){_this._el.removeAttribute(_this.stateChangeAttribute),resolve(from,null);return}var running=!0;if(_this.cancelRunning=function(){running=!1,resolve(null,null)},_this._el.removeEventListener(_this.endEvent,_this.activeEventHandler),_this.activeEventHandler=null,force){_this._el.setAttribute(_this.stateChangeAttribute,"".concat(from,"=>").concat(to)),_this.onStart({el:_this._el,from:from,to:to}),typeof options.onStart=="function"&&options.onStart({el:_this._el,from:from,to:to}),_this._el.setAttribute(_this.stateAttribute,to),_this._state=to,hold||_this._el.removeAttribute(_this.stateChangeAttribute),resolve(to,null);return}raf().then(function(){if(!running)throw new Error("cancelled");return _this._el.setAttribute(_this.stateChangeAttribute,"".concat(from,"=>").concat(to)),_this.onStart({el:_this._el,from:from,to:to}),typeof options.onStart=="function"&&options.onStart({el:_this._el,from:from,to:to}),raf()}).then(function(){if(!running)throw new Error("cancelled");_this._el.removeEventListener(_this.endEvent,_this.activeEventHandler),_this.activeEventHandler=function(e){e.target!==_this._el||!running||(_this._el.removeEventListener(_this.endEvent,_this.activeEventHandler),hold||_this._el.removeAttribute(_this.stateChangeAttribute),resolve(to,e))},_this._el.addEventListener(_this.endEvent,_this.activeEventHandler),_this._el.setAttribute(_this.stateAttribute,to),_this._state=to}).catch(function(error){if(error.message!=="cancelled")throw error})})}},{key:"unload",value:function(){this._el.removeEventListener(this.endEvent,this.activeEventHandler),this.activeEventHandler=null}},{key:"el",get:function(){return this._el}},{key:"state",get:function(){return this._state}}]),Animation2})(),AnimationsManager=(function(){function AnimationsManager2(){_classCallCheck(this,AnimationsManager2),this.animations=new Map}return _createClass(AnimationsManager2,[{key:"add",value:function(options){if(this.animations.has(options.el))return this.animations.get(options.el);var animation2=new Animation(options);return this.animations.set(options.el,animation2),animation2}},{key:"remove",value:function(animation2){this.animations.delete(animation2.el),animation2.unload()}},{key:"removeAll",value:function(){this.animations.forEach(function(animation2){return animation2.unload()})}}]),AnimationsManager2})();function animation(options){var setOptions={endEvent:"animationend",hold:!0};return new Animation(_objectSpread2({options:options},setOptions))}function transition(options){return new Animation(options)}export{Animation,AnimationsManager,animation,transition}; 6//# sourceMappingURL=/cdn/shop/t/57/assets/util.animations.js.map?v=88379227021148447571784097581
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.