-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathriotAnimate.min.js
1 lines (1 loc) · 3.25 KB
/
riotAnimate.min.js
1
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.riotAnimate=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var OptsAnimateMixin={init:function(){this.on("mount",function(){createAnimation.call(this,"enter");var animationEnded=function(e){var item=e.target;if(this.enterClasses){this.enterClasses.forEach(function(classToAnimate){item.classList.remove(classToAnimate)})}if(this.leaveClasses){this.leaveClasses.forEach(function(classToAnimate){item.classList.remove(classToAnimate)})}item.classList.remove("animated");item.classList.remove("riot-enter-active");item.classList.remove("riot-enter");item.classList.remove("riot-animate");item.classList.remove("riot-leave-active");item.classList.remove("riot-leave");item.classList.remove("riot-animate");var delay=item.getAttribute("animate-delay");if(delay){item.style.animationDelay="";item.style.transitionDelay=""}var duration=item.getAttribute("animate-duration");if(duration){item.style.animationDuration="";item.style.transitionDuration=""}}.bind(this);this.root.addEventListener("transitionend",animationEnded,false);this.root.addEventListener("animationend",animationEnded,false)})},animatedUnmount:function(keepParent){createAnimation.call(this,"leave");var waitFor=1;var unmount=function(e){e.target.style.visibility="hidden";if(waitFor===this.animatedDomElements.length){this.unmount(keepParent)}else{waitFor++}}.bind(this);this.root.addEventListener("transitionend",unmount,false);this.root.addEventListener("animationend",unmount,false)}};function createAnimation(ANIMATION_NAME){this.animatedDomElements=this.root.querySelectorAll("[animate]");for(var x=0;x<this.animatedDomElements.length;x++){var item=this.animatedDomElements[x];var attributeToAnimate=item.getAttribute("animate-"+ANIMATION_NAME);if(!attributeToAnimate){var attributeToAnimate=item.getAttribute("animate")}this.enterClasses=attributeToAnimate.split(" ");this.enterClasses.forEach(function(classToAnimate){item.classList.add(classToAnimate)});var delay=item.getAttribute("animate-delay");if(delay){item.style.animationDelay=delay;item.style.transitionDelay=delay}var duration=item.getAttribute("animate-duration");if(duration){item.style.animationDuration=duration;item.style.transitionDuration=duration}item.classList.add("riot-"+ANIMATION_NAME)}window.requestAnimationFrame(function(){for(var x=0;x<this.animatedDomElements.length;x++){var item=this.animatedDomElements[x];item.classList.add("animated");item.classList.add("riot-animate");item.classList.add("riot-"+ANIMATION_NAME+"-active")}}.bind(this))}module.exports=OptsAnimateMixin},{}]},{},[1])(1)});