UNPKG

ng-slide-animations

Version:

Minimal angular.js implementation of slide-to-side animations

1 lines 1.18 kB
angular.module("ngSlideAnimations",[]).factory("slideAnimations",["$window",function(t){function n(t){var n=angular.element("<p/>")[0].style,e=["ms","O","Moz","Webkit"];if("string"==typeof n[t])return t;t=t.charAt(0).toUpperCase()+t.substr(1);for(var i=e.length;i--;)if("string"==typeof n[e[i]+t])return e[i]+t}function e(t,n,e,a,u){if(o(t,n)){e==f&&(e=i(t,n)),a==f&&(a=i(t,n));var l=t[0].style[n],c=t[0].style.display;t.css("display","none").css(n,e),r(s(t),n,l,u),s(t.css("display",c)).css(n,a)}else u&&u()}function i(n,e){var i=t.getComputedStyle(n[0])[e];return isNaN(parseFloat(i))?n[0].getBoundingClientRect()[e]+"px":i}function r(t,n,e,i){t.on("transitionend",function r(o){o.propertyName!=n&&o.propertyName||(t.off("transitionend",r),t.css(n,e),i&&i())})}function o(n,e){var i=t.getComputedStyle(n[0]),r=i[a];return!(""==r||"none"==r||"all"!==r&&!~r.split(/\s*,\s*/).indexOf(e))&&parseFloat(i[u])>0}function s(t){return t[0].offsetHeight,t}var a=n("transitionProperty"),u=n("transitionDuration"),f="current";return{down:function(t,n){e(t,"height",0,f,n)},up:function(t,n){e(t,"height",f,0,n)},right:function(t,n){e(t,"width",0,f,n)},left:function(t,n){e(t,"width",f,0,n)}}}]);