This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blob-slide.min.js
12 lines (12 loc) · 4.54 KB
/
blob-slide.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/**
* Blob-slide
*
* @version 1.3.2
* @author Blobfolio, LLC <[email protected]>
* @package blob-slide
* @license WTFPL <http://www.wtfpl.net>
*
* @see https://github.com/Blobfolio/blob-slide
* @see https://blobfolio.com
*/
!function(){let t={};const n={linear:function(t){return t},ease:function(t){return.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return.5>t?2*t*t:(4-2*t)*t-1},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return.5>t?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return.5>t?16*t*t*t*t*t:1+16*--t*t*t*t*t}};function e(t){if(!t.nodeType)return!1;if(!d(t))return{width:0,height:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0};const n=window.getComputedStyle(t,null);return{width:parseFloat(n.width)||0,height:parseFloat(n.height)||0,paddingTop:parseFloat(n.paddingTop)||0,paddingRight:parseFloat(n.paddingRight)||0,paddingBottom:parseFloat(n.paddingBottom)||0,paddingLeft:parseFloat(n.paddingLeft)||0,marginTop:parseFloat(n.marginTop)||0,marginRight:parseFloat(n.marginRight)||0,marginBottom:parseFloat(n.marginBottom)||0,marginLeft:parseFloat(n.marginLeft)||0}}function i(t){if(!t.nodeType)return!1;const n=t.parentNode,i=t.cloneNode(!0);i.hidden=null,i.style.cssText="display:block;visibility:visible;opacity:0",n.appendChild(i);const r=e(i);return n.removeChild(i),r}function r(n,e){const r=parseInt(n.getAttribute("data-progress-key"),10)||!1;return r&&("show"===t[r].end?e.force="hide":e.force="show"),"show"===e.force?i(n):"hide"===e.force?{width:0,height:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}:function(t){return!!t.nodeType&&(d(t)?{width:0,height:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}:i(t))}(n)}function o(t){return null!=t}function a(t){return null!==t&&"object"==typeof t}function d(t){if(!t.nodeType||t.hidden)return!1;return"none"!==window.getComputedStyle(t,null).display}function u(t){return null==t}window.blobSlide={hslide:function(t,n){if(t instanceof NodeList){const e=t.length;for(let i=0;i<e;++i)this.hslide(t[i],n);return}const e=r(t,n);if(!1===e)return;const i={width:e.width,paddingRight:e.paddingRight,paddingLeft:e.paddingLeft,marginRight:e.marginRight,marginLeft:e.marginLeft};return this.slide(t,i,n)},vslide:function(t,n){if(t instanceof NodeList){const e=t.length;for(let i=0;i<e;++i)this.vslide(t[i],n);return}const e=r(t,n);if(!1===e)return;const i={height:e.height,paddingTop:e.paddingTop,paddingBottom:e.paddingBottom,marginTop:e.marginTop,marginBottom:e.marginBottom};return this.slide(t,i,n)},slide:function(i,r,s){if(!i.nodeType||!function(t){if(!a(t))return!1;for(let n in t)return!0;return!1}(r))return;const g=parseInt(i.getAttribute("data-progress-key"),10)||!1;g&&o(t[g])&&(t[g].abort=!0),a(s)||(s={}),s.duration=parseInt(s.duration,10)||0,0>=s.duration&&(s.duration=100),s.display&&"string"==typeof s.display?(s.display=s.display.toLowerCase(),"none"===s.display&&(s.display="block")):s.display="block",s.transition&&!u(n[s.transition])||(s.transition="linear");let p=parseInt((Math.random()+"").replace(".",""),10);for(;o(t[p]);)++p;i.setAttribute("data-progress-key",p),t[p]={abort:!1,end:"hide"};const l=e(i);let f=Object.keys({width:0,height:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0}),h={},c=null;for(let t=0;10>t;++t)"number"==typeof r[f[t]]&&r[f[t]]!==l[f[t]]&&(h[f[t]]=[l[f[t]],r[f[t]],r[f[t]]-l[f[t]]]);const m=(f=Object.keys(h)).length;if(!m)return delete t[p],void i.removeAttribute("data-progress-key");(o(h.width)&&0<h.width[1]||o(h.height)&&0<h.height[1])&&(t[p].end="show"),d(i)||(i.hidden=null,i.style.display=s.display),i.style.overflow="hidden";const y=function(e){if(u(t[p])||t[p].abort)return;null===c&&(c=e);const r=e-c,o=Math.min(r/s.duration,1),a=n[s.transition](o);for(let t=0;t<m;++t){const n=h[f[t]][0],e=h[f[t]][2];i.style[f[t]]=n+e*a+"px"}1>a?window.requestAnimationFrame(y):("show"===t[p].end?i.style.display=s.display:(i.hidden=!0,i.style=null),delete t[p],i.removeAttribute("data-progress-key"))};window.requestAnimationFrame(y),g&&delete t[g]}}}();