/
var
/
www
/
barefootlaw.org
/
wp-content
/
themes
/
archub
/
assets
/
vendors
/
momentum-slider
/
Upload File
HOME
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):t.MomentumSlider=i()}(this,(function(){"use strict";function t(t){this.o=r({},this.defaults,t),this.initHtml(),this.initValues(),this.initEvents(),this.updateClassnames()}function i(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function e(t,e){if(e in t.style)return getComputedStyle(t).getPropertyValue(i(e))||"0"}function s(t){return'<li class="ms-slide">'+t+"</li>"}function n(t,i){for(var e in i)t[e]=l.arr(i[e])?i[e].slice(0):i[e];return t}function r(t){t||(t={});for(var i=1;i<arguments.length;i++)n(t,arguments[i]);return t}function o(t,i,e){if(i){var s=performance.now(),n=null,r=!1,o=function(h){var a=(h-s)/i;a<0&&(a=0),a>1&&(a=1),l.fnc(e)&&(a=e(a)),t(a),1===a||r||(n=requestAnimationFrame(o))};return n=requestAnimationFrame(o),new function(){this.stop=function(){n&&cancelAnimationFrame(n),r=!0}}}t(1)}function h(){var t=!1;try{var i=Object.defineProperty({},"passive",{get:function i(){t=!0}});window.addEventListener("test",null,i)}catch(t){}return h=function(){return t},t}function a(t){if("touchmove"===t.type||"touchstart"===t.type||"touchend"===t.type){var i=t.targetTouches[0]||t.changedTouches[0];return{x:i.clientX,y:i.clientY,id:i.identifier}}return{x:t.clientX,y:t.clientY,id:null}}function d(t){return 5e-6*Math.pow(t,2)+1e-4*t+.55}function c(t,i,e){var s=t[0],n=t[1],r=t[2]||s,o=e?n-s:n-r;return e?n-o*i:n+o*i}window.addEventListener("touchmove",(function(){})),t.prototype={defaults:{el:".ms-container",cssClass:"",vertical:!1,multiplier:1,bounceCoefficient:.3,bounceMax:100,loop:0,interactive:!0,reverse:!1,currentIndex:0},initHtml:function(){if(this.msContainer=l.str(this.o.el)?document.querySelector(this.o.el):this.o.el,this.o.range){for(var t='<div class="ms-container '+this.o.cssClass+'"><ul class="ms-track">',i=this.o.range[0];i<=this.o.range[1];i++)t+=l.fnc(this.o.rangeContent)?s(this.o.rangeContent(i)):s(i);t+="</ul></div>";var e=document.createElement("div");e.innerHTML=t,this.msContainer.appendChild(e.firstChild),this.msContainer=this.msContainer.lastChild}if(this.msContainer.classList.add("ms-container--"+(this.o.vertical?"vertical":"horizontal")),this.o.reverse&&this.msContainer.classList.add("ms-container--reverse"),this.msTrack=this.msContainer.children[0],this.msSlides=this.msTrack.children,this.step=this.o.vertical?this.msSlides[0].scrollHeight:this.msSlides[0].scrollWidth,this.sliderLength=this.msSlides.length,this.o.loop){var n,r,o;for(o=document.createDocumentFragment(),n=this.o.loop,r=this.sliderLength-n;n--;)o.appendChild(this.msSlides[r++].cloneNode(!0));for(this.msTrack.insertBefore(o,this.msTrack.firstChild),o=document.createDocumentFragment(),r=n=this.o.loop;n--;)o.appendChild(this.msSlides[r++].cloneNode(!0));this.msTrack.appendChild(o),this.sliderLength+=2*this.o.loop}this.sliderWidth=this.sliderLength*this.step},initValues:function(){this.boundMin=this.o.reverse?0:-this.step*(this.sliderLength-1),this.boundMax=this.o.reverse?this.step*(this.sliderLength-1):0,this.targetPosition=this.targetPosition||0,this.ticking=!1,this.enabled=!0,this.pointerActive=!1,this.pointerMoved=!1,this.trackingPoints=[],this.msTrack.style[this.o.vertical?"height":"width"]=this.sliderWidth+"px",this.currentIndex=(this.currentIndex||this.o.currentIndex)+this.o.loop,this.updateSlider(void 0,!0),this.renderTarget();for(var t=this.sliderLength;t--;)this.setStyle(t,this.currentIndex==t?0:-1)},initEvents:function(){this.o.interactive&&(this.msContainer.addEventListener("touchstart",this.onDown.bind(this)),this.msContainer.addEventListener("mousedown",this.onDown.bind(this)),document.addEventListener("touchmove",this.onMove.bind(this),!!h()&&{passive:!1}),document.addEventListener("touchend",this.onUp.bind(this)),document.addEventListener("touchcancel",this.stopTracking.bind(this)),document.addEventListener("mousemove",this.onMove.bind(this),!!h()&&{passive:!1}),document.addEventListener("mouseup",this.onUp.bind(this)),this.o.prevEl&&(this.prevEl=l.str(this.o.prevEl)?document.querySelector(this.o.prevEl):this.o.prevEl,this.prevEl.addEventListener("click",this.prev.bind(this))),this.o.nextEl&&(this.nextEl=l.str(this.o.nextEl)?document.querySelector(this.o.nextEl):this.o.nextEl,this.nextEl.addEventListener("click",this.next.bind(this)))),window.addEventListener("resize",this.onResize.bind(this))},prev:function(){this.enabled&&this.updateSlider(Math.round(this.targetPosition/this.step)*this.step+(this.o.reverse?-this.step:this.step))},next:function(){this.enabled&&this.updateSlider(Math.round(this.targetPosition/this.step)*this.step+(this.o.reverse?this.step:-this.step))},select:function(t){this.enabled&&this.updateSlider((t+this.o.loop)*(this.o.reverse?this.step:-this.step))},setStyleToNode:function(t,i,e,s){if(i){var n="";for(var r in i)"."==r[0]?this.setStyleToNode(t.querySelector(r),i[r],e,s):"transform"==r?i[r].forEach((function(t){for(var i in t)n+=i+"("+c(t[i],e,s),"rotate"==i?n+="deg":"translateX"!=i&&"translateY"!=i&&"translateZ"!=i||(n+="px"),n+=") "})):n=c(i[r],e,s),t.style[r]=n}},setStyle:function(t,i,e){this.setStyleToNode(this.msSlides[t],this.o.style,i,e),l.fnc(this.o.customStyles)&&this.o.customStyles(t,i,e)},renderTarget:function(){if(this.o.sync)for(var t=this.o.sync.length,i;t--;)(i=this.o.sync[t]).targetPosition=(i.o.reverse?-1:1)*this.targetPosition/this.sliderWidth*i.sliderWidth,i.renderTarget();var e=this.o.loop*this.step,s=this.sliderWidth-2*e;if(this.o.loop)if(-this.targetPosition<e)for(;-this.targetPosition<e;)this.targetPosition-=s;else if(-this.targetPosition>=e+s)for(;-this.targetPosition>=e+s;)this.targetPosition+=s;var n=(this.o.reverse?1:-1)*this.targetPosition/this.step;this.onChangeCurrentIndex(Math.round(n));var r=Math.floor(n),o=Math.ceil(n),h=n-r,a=n-o;l.und(this.lowerIndex)||this.lowerIndex==r||this.lowerIndex==o||this.setStyle(this.lowerIndex,1,!0),l.und(this.higherIndex)||this.higherIndex==r||this.higherIndex==o||this.setStyle(this.higherIndex,-1),r>=0&&r<this.sliderLength&&(this.setStyle(r,h,!0),this.lowerIndex=r),o>=0&&o<this.sliderLength&&(this.setStyle(o,a),this.higherIndex=o);var d="translate"+(this.o.vertical?"Y":"X")+"("+this.targetPosition+"px)";this.msTrack.style[p]=d},onDown:function(t){if(document.getElementsByTagName("html")[0].classList.add("slider-pointer-down"),this.enabled&&!this.pointerActive){var i=a(t);this.pointerActive=!0,this.pointerId=i.id,this.pointerLastX=this.pointerCurrentX=i.x,this.pointerLastY=this.pointerCurrentY=i.y,this.trackingPoints=[],this.addTrackingPoint(this.pointerLastX,this.pointerLastY),this.animateInstance&&this.animateInstance.stop()}},onMove:function(t){if(this.enabled&&this.pointerActive){this.pointerMoved=!0,t.preventDefault();var i=a(t);i.id===this.pointerId&&(this.pointerCurrentX=i.x,this.pointerCurrentY=i.y,this.addTrackingPoint(this.pointerLastX,this.pointerLastY),this.requestTick())}},onUp:function(t){var i;if((document.getElementsByTagName("html")[0].classList.remove("slider-pointer-down"),this.enabled&&this.pointerActive)&&a(t).id===this.pointerId){var e=t.target;if(this.msTrack.contains(e))for(;!e.matches(".ms-slide, .ms-track");)e=e.parentNode;var s=Array.prototype.indexOf.call(this.msSlides,e);this.pointerMoved||-1!==s&&(this.currentIndex=s,this.updateSlider()),this.stopTracking(s)}},onResize:function(){},stopTracking:function(t){this.pointerActive=!1,(this.pointerMoved||-1===t)&&(this.pointerMoved=!1,this.addTrackingPoint(this.pointerLastX,this.pointerLastY),this.startDecelAnim())},addTrackingPoint:function(t,i){for(var e=Date.now();this.trackingPoints.length>0&&!(e-this.trackingPoints[0].time<=100);)this.trackingPoints.shift();this.trackingPoints.push({x:t,y:i,time:e})},updateAndRender:function(){var t=this.o.vertical?this.pointerCurrentY-this.pointerLastY:this.pointerCurrentX-this.pointerLastX;if(this.targetPosition+=t*this.o.multiplier,this.o.bounceCoefficient){var i=this.checkBounds();0!==i&&(this.targetPosition-=t*d(i)*this.o.multiplier)}else this.checkBounds(!0);this.renderTarget(),this.pointerLastX=this.pointerCurrentX,this.pointerLastY=this.pointerCurrentY,this.ticking=!1},requestTick:function(){this.ticking||requestAnimationFrame(this.updateAndRender.bind(this)),this.ticking=!0},checkBounds:function(t){var i=0;return void 0!==this.boundMin&&this.targetPosition<this.boundMin?i=this.boundMin-this.targetPosition:void 0!==this.boundMax&&this.targetPosition>this.boundMax&&(i=this.boundMax-this.targetPosition),t&&0!==i&&(this.targetPosition=i>0?this.boundMin:this.boundMax),i},startDecelAnim:function(){var t=this.trackingPoints[0],i=this.trackingPoints[this.trackingPoints.length-1],e=this.o.vertical?i.y-t.y:i.x-t.x,s,n=(i.time-t.time)/15/this.o.multiplier;this.decVel=e/n||0;var r=this.targetPosition+12*this.decVel,o=r%this.step;r-=o,Math.abs(o)>this.step/2&&(r+=(o>0?1:-1)*this.step),this.updateSlider(r)},fixCurrentIndex:function(){this.o.loop&&(this.currentIndex<this.o.loop?this.currentIndex=this.sliderLength-this.o.loop+(this.currentIndex-this.o.loop):this.currentIndex>this.sliderLength-this.o.loop-1&&(this.currentIndex=this.currentIndex+2*this.o.loop-this.sliderLength))},updateSlider:function(t,i){l.und(t)?t=(this.o.reverse?1:-1)*this.currentIndex*this.step:this.currentIndex=(this.o.reverse?1:-1)*t/this.step,this.fixCurrentIndex(),t!==this.targetPosition&&(this.updateClassnames(),this.animateTarget(t,i))},updateClassnames:function(){this.prevEl&&(0===this.currentIndex?this.prevEl.classList.add("ms-first"):this.prevEl.classList.remove("ms-first")),this.nextEl&&(this.currentIndex===this.sliderLength-1?this.nextEl.classList.add("ms-last"):this.nextEl.classList.remove("ms-last"))},animateTarget:function(t,i,e){this.animateInstance&&this.animateInstance.stop();var s=this,n=this.targetPosition,r=t;this.animateInstance=o((function(t){s.targetPosition=r>n?n+(r-n)*t:n-(n-r)*t;var i=s.o.reverse?0:-(s.sliderLength-1)*s.step,o=s.o.reverse?(s.sliderLength-1)*s.step:0;!e&&!s.o.loop&&s.o.bounceCoefficient&&(s.targetPosition>o&&s.targetPosition>o+Math.min((r-o)*s.o.bounceCoefficient,s.o.bounceMax)||s.targetPosition<i&&s.targetPosition<i-Math.min(-(r-i)*s.o.bounceCoefficient,s.o.bounceMax))?(s.animateInstance.stop(),s.animateTarget(s.targetPosition<i?i:o,!1,!0),s.currentIndex=s.targetPosition<i?0:s.sliderLength-1):s.renderTarget()}),i?0:500,(function(t){return t*(2-t)}))},onChangeCurrentIndex:function(t){var i=this.o.loop?t-this.o.loop:t;i=i===this.sliderLength-2*this.o.loop?0:i,l.fnc(this.o.change)&&i!==this.lastCurrentIndex&&(this.o.change(i,this.lastCurrentIndex),this.lastCurrentIndex=i)},getCurrentIndex:function(){return this.o.loop?this.currentIndex-this.o.loop:this.currentIndex},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1}};var l={arr:function(t){return Array.isArray(t)},str:function(t){return"string"==typeof t},und:function(t){return void 0===t},fnc:function(t){return"function"==typeof t}},u="transform",p=e(document.body,u)?u:"-webkit-"+u;return r(t,{extend:r,transformProperty:p,getCurrentValue:c})}));