-
Notifications
You must be signed in to change notification settings - Fork 25
/
vimeowrap.carousel.js
1 lines (1 loc) · 9.23 KB
/
vimeowrap.carousel.js
1
!function(t,e){function i(i){"ontouchstart"in t&&(this.element="object"==typeof i?i:e.getElementById(i),this.element.addEventListener("touchstart",this,!1),this.element.addEventListener("click",this,!0))}var A=A||function(){var t,e,i,A=60,n=!1,s=[];return{setFPS:function(t){A=t||60},start:function(t){0!==arguments.length&&this.setFPS(t),e=setInterval(this.update,1e3/A)},stop:function(){clearInterval(e)},setAutostart:function(t){n=t,n&&!e&&this.start()},add:function(t){s.push(t),n&&!e&&this.start()},getAll:function(){return s},removeAll:function(){s=[]},remove:function(e){t=s.indexOf(e),-1!==t&&s.splice(t,1)},update:function(e){t=0,i=s.length;for(var A=e||(new Date).getTime();i>t;)s[t].update(A)?t++:(s.splice(t,1),i--);0===i&&n===!0&&this.stop()}}}();A.Tween=function(t){var e=t,i={},n={},s={},a=1e3,o=0,h=null,r=A.Easing.Linear.EaseNone,l=null,u=null,d=null;this.to=function(t,i){null!==i&&(a=i);for(var A in t)null!==e[A]&&(s[A]=t[A]);return this},this.start=function(t){A.add(this),h=t?t+o:(new Date).getTime()+o;for(var a in s)null!==e[a]&&(i[a]=e[a],n[a]=s[a]-e[a]);return this},this.stop=function(){return A.remove(this),this},this.delay=function(t){return o=t,this},this.easing=function(t){return r=t,this},this.chain=function(t){return l=t,this},this.onUpdate=function(t){return u=t,this},this.onComplete=function(t){return d=t,this},this.update=function(t){var A,s,o;if(h>t)return!0;s=(t-h)/a,s=s>1?1:s,o=r(s);for(A in n)e[A]=i[A]+n[A]*o;return null!==u&&u.call(e,o),1==s?(null!==d&&d.call(e),null!==l&&l.start(),!1):!0}},A.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}},A.Easing.Exponential.EaseIn=function(t){return 0===t?0:Math.pow(2,10*(t-1))},A.Easing.Exponential.EaseOut=function(t){return 1==t?1:-Math.pow(2,-10*t)+1},A.Easing.Exponential.EaseInOut=function(t){return 0===t?0:1==t?1:(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*(t-1))+2)},vimeowrap.carousel=function(n,s){function a(t){u.length=t.length;var i=u.width-2*s.offsetx;u.visible=s.visible>0?s.visible:Math.floor(i/s.thumb.width);for(var A=Math.round((i-u.visible*s.thumb.width)/Math.max(u.visible-1,1)),n=[],a=s.template,o=0;o<t.length;o++)n.push('<li style="margin-right:'+A+'px;">'),n.push(a.populate(t[o])),n.push("</li>");var h=e.getElementById(r.id+"_list");h.innerHTML=n.join(""),u.offset=s.thumb.width+A,vimeowrap.utils.css(h,{width:t.length*u.offset})}function o(e){var i=e||t.event,A=i.target||i.srcElement;if(A&&"li"!==A.nodeName.toLowerCase())for(;A&&(A=A.parentNode,"li"!==A.nodeName.toLowerCase()););for(var a=0,o=A.parentNode.children,h=0;h<o.length&&(a=h,o[h]!==A);h++);return a!==n.config.item&&n.playlistItem(a,s.autoplay),!1}function h(){l.style.left=u.xx+"px"}var r,l,u=this,d={position:"bottom",size:130,offsetx:50,offsety:10,autoplay:!1,template:'<a href="{{url}}" title="{{title}}"><img src="{{thumbnail_'+(s.thumb&&s.thumb.quality?s.thumb.quality:"small")+'}}" alt="" /><span>{{title}}</span></a>',style:"",easing:A.Easing.Exponential.EaseInOut,speed:250,thumb:{width:100,height:75}};s=vimeowrap.utils.extend(d,s),this.config=s,this.xx=0,this.visible=0,this.position=0,this.offset=0,this.length=0,A.start(),this.setup=function(){var A=s.fontdir||"https://luwes.github.io/vimeowrap.js/fonts/",h="@font-face {font-family:'Pictish'; src:url('"+A+"pictish.eot'); src:url('"+A+"pictish.eot?#iefix') format('embedded-opentype'), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAdcABEAAAAACsQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABgAAAABwAAAAcYSxV1EdERUYAAAGc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PGhr+3Dn1PcEf3PHyr613jhq+LV4x//+AbUAlLdwB42m3NOw6CUBSE4RlQ8A1q4zIuV/HRGEnApYAmxthYuC1dhNsSPVP6N18yzSCA9UaNfy0ABgzZQYg9DuwyYswe+xxwyBHHnDBhiidenHLGedRcHrdTZvj4fj0750qzcF99O8hMermUK5nLtdzIrdzJwvRHM/9ZtT8fxXkqqQAAALgB/4WwAY0AS7AIUFixAQGOWbFGBitYIbAQWUuwFFJYIbCAWR2wBitcWFmwFCsAAAABT+IqwQAA) format('woff'), url('"+A+"pictish.ttf') format('truetype'), url('"+A+"pictish.svg#PictishRegular') format('svg'); font-weight:normal; font-style:normal;}#{{id}} a {text-decoration:none;}#{{id}} a:active, #{{id}} a:focus {outline:none;}#{{id}} {font:bold 12px/14px helvetica,arial,sans-serif;-webkit-tap-highlight-color:rgba(0,0,0,0);}#{{id}} ul {margin:0;padding:0;}#{{id}} ul li {display:block;float:left;width:{{thumb_width}}px;line-height:14px;}#{{id}} ul li a {display:block;color:#{{color}};text-align:center;}#{{id}} ul li a img {border:none;width:{{thumb_width}}px;height:{{thumb_height}}px;}#{{id}}_navleft, #{{id}}_navright {color:#000;display:block;font-family:'Pictish';font-size:19px;position:absolute;top:32px;width:20px;height:19px;padding:10px;}#{{id}}_navright {right:0;}";h+="ontouchstart"in t?"#{{id}} ul li a.pressed {color:#F75342;}#{{id}}_navleft.pressed, #{{id}}_navright.pressed {color:#{{color}};}":"#{{id}} ul li a:hover {color:#F75342;}#{{id}}_navleft:hover, #{{id}}_navright:hover {color:#{{color}};}",h+=s.style;var u=e.createTextNode(h.populate({id:n.id+"_carousel",color:n.config.color,thumb_width:s.thumb.width,thumb_height:s.thumb.height})),d=e.createElement("style");d.type="text/css",vimeowrap.utils.prepend(d,e.getElementsByTagName("head")[0]),d.styleSheet?d.styleSheet.cssText=u.nodeValue:d.appendChild(u),r=e.createElement("div"),r.id=n.id+"_carousel",n.container.appendChild(r),vimeowrap.utils.css(r,{width:this.width,height:this.height,position:"absolute",left:this.x,top:this.y}),new i(r);var c=e.createElement("div");c.id=r.id+"_wrap",r.appendChild(c),vimeowrap.utils.css(c,{width:this.width-2*s.offsetx,height:this.height-s.offsety,overflow:"hidden",position:"absolute",left:s.offsetx,top:s.offsety}),l=e.createElement("ul"),l.id=r.id+"_list",c.appendChild(l),vimeowrap.utils.css(l,{height:this.height,position:"absolute","list-style":"none"}),l.onclick=o;var p=e.createElement("a");p.id=r.id+"_navleft",p.href="#left",p.innerHTML="<span>[</span>",r.appendChild(p),p.onclick=this.left;var f=e.createElement("a");f.id=r.id+"_navright",f.href="#right",f.innerHTML="<span>]</span>",r.appendChild(f),f.onclick=this.right,n.events.playlist.add(a)},this.left=function(){return u.position>0&&u.to(u.position-u.visible),!1},this.right=function(){return u.position<u.length-u.visible&&u.to(u.position+u.visible),!1},this.to=function(t){return u.position=t,new A.Tween(u).to({xx:-t*u.offset},s.speed).onUpdate(h).easing(s.easing).start(),!1}},i.prototype={handleEvent:function(t){this[t.type](t)},touchstart:function(t){this.moved=!1,this.theTarget=e.elementFromPoint(t.targetTouches[0].clientX,t.targetTouches[0].clientY),3==this.theTarget.nodeType&&(this.theTarget=theTarget.parentNode),this.theTarget.className+=" pressed",this.element.addEventListener("touchmove",this,!1),this.element.addEventListener("touchend",this,!1)},touchmove:function(){this.moved=!0,this.theTarget.className=this.theTarget.className.replace(/ ?pressed/gi,"")},touchend:function(t){if(t.preventDefault(),this.element.removeEventListener("touchmove",this,!1),this.element.removeEventListener("touchend",this,!1),!this.moved&&this.theTarget){this.theTarget.className=this.theTarget.className.replace(/ ?pressed/gi,"");var i=e.createEvent("MouseEvents");i.initEvent("click",!0,!0),this.theTarget.dispatchEvent(i)}this.theTarget=void 0},click:function(t){void 0===this.theTarget&&(t.stopImmediatePropagation(),t.preventDefault())}}}(window,document);