text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Film=e()}(this,function(){"use strict";function t(t){if("string"==typeof t)return document.querySelector(t);if(t.tagName)return t;throw new TypeError("Film.js: invalid el")}var e=function(t){for(var e=arguments,i=1;i<arguments.length;i++){var r=e[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i={frameWidth:null,framesPerView:3,speed:20,direction:"left"},r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return setTimeout(t,16)},n=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame||window.clearTimeout,o=function(r,n){var o=this;this.el=t(r),this.opts=e({},i,n),this.frames=[],this._initWrapper();for(var a=this.el.querySelectorAll(".film__frame"),s=0;s<a.length;s++){var f=a[s];o._initFrame(f,s),o.frames.push(f)}this.start()},a={started:{}};return o.prototype._initWrapper=function(){this.el.style.overflow="hidden"},o.prototype._initFrame=function(t,e){if(this.opts.frameWidth)t.moveVal=e*this.opts.frameWidth,t.style.width=this.opts.frameWidth+"px";else{var i=window.innerWidth;t.moveVal=e*i/this.opts.framesPerView,t.style.width="calc(100vw / "+this.opts.framesPerView+")"}t.style.position="absolute",t.style.transform="translateX("+t.moveVal+"px)",t.style["z-index"]=e},o.prototype._update=function(){var t,e=this,i=[],n=this.opts.speed/16;switch(this.opts.direction){case"left":t=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];return(r=e)._updateLeft.apply(r,t);var r};break;case"right":t=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];return(r=e)._updateRight.apply(r,t);var r};break;default:throw new Error("Film.js: invalid direction")}this.frames.forEach(function(e,r){t(e,r,n),i.push(function(){e.style.transform="translateX("+e.moveVal+"px)"})}),i.forEach(function(t){return t()}),this.reqId=r(function(){return e._update()})},o.prototype._updateLeft=function(t,e,i){if(t.moveVal-=i,t.moveVal+t.clientWidth<-10){var r=0===e?e=this.frames.length-1:e-1,n=this.frames[r];t.moveVal=Math.floor(n.moveVal+n.clientWidth-i-1)}},o.prototype._updateRight=function(t,e,i){if(t.moveVal+=i,t.moveVal-window.innerWidth>10){var r=e===this.frames.length-1?0:e+1,n=this.frames[r];t.moveVal=Math.floor(n.moveVal-n.clientWidth+i+1)}},o.prototype.start=function(){var t=this;this.reqId=r(function(){return t._update()})},o.prototype.stop=function(){this.reqId&&(n(this.reqId),this.reqId=null)},o.prototype.refresh=function(){var t=this;this.stop(),this.frames.forEach(function(e,i){t._initFrame(e,i)}),this.start()},a.started.get=function(){return null!==this.reqId},Object.defineProperties(o.prototype,a),o});
  