1/* 2infiniteslide.js v2 3version: 2.0.1 4Author: T.Morimoto 5 6Copyright 2017, T.Morimoto 7* Free to use and abuse under the MIT license. 8* http://www.opensource.org/licenses/mit-license.php 9 10https://github.com/woodroots/infiniteslidev2 11*/ 12 13(function($){ 14 $(window).on('load', function() { 15 window.loaded = true; 16 }); 17 $(function(){ 18 $.fn.infiniteslide = function(options){ 19 //option 20 var settings = $.extend({ 21 'speed': 100, //éããåä½ã¯px/ç§ã§ãã 22 'direction': 'left', //up/down/left/rightãã鏿 23 'pauseonhover': true, //ãã¦ã¹ãªã¼ãã¼ã§ã¹ããã 24 'responsive': false, //åè¦ç´ ã®å¹ ã%ã§æå®ãã¦ããã¨ã 25 'clone': 1 26 },options); 27 28 var setCss = function(obj,direction){ 29 $(obj).wrap('<div class="infiniteslide_wrap"></div>').parent().css({ 30 overflow: 'hidden' 31 }); 32 33 if(direction == 'up' || direction == 'down'){ 34 var d = 'column'; 35 } else { 36 var d = 'row'; 37 } 38 39 $(obj).css({ 40 display: 'flex', 41 flexWrap: 'nowrap', 42 alignItems: 'center', 43 '-ms-flex-align': 'center', 44 flexDirection: d 45 }).children().css({ 46 flex: 'none', 47 display: 'block' 48 }); 49 } 50 51 var setClone = function(obj,clone){ 52 var $clone = $(obj).children().clone(true).addClass('infiniteslide_clone'); 53 var i = 1; 54 while(i <= clone){ 55 $clone.clone(true).appendTo($(obj)); 56 i++; 57 } 58 } 59 60 var getWidth = function(obj){ 61 var w = 0; 62 $(obj).children(':not(.infiniteslide_clone)').each(function(key,value){ 63 w = w + $(this).outerWidth(true); 64 }); 65 return w; 66 } 67 var getHeight = function(obj){ 68 var h = 0; 69 $(obj).children(':not(.infiniteslide_clone)').each(function(key,value){ 70 h = h + $(this).outerHeight(true); 71 }); 72 return h; 73 } 74 75 76 var getSpeed = function(l,s){ 77 return l / s; 78 } 79 var getNum = function(obj,direction){ 80 var num = 0; 81 if(direction == 'up' || direction == 'down'){ 82 num = getHeight(obj); 83 } else { 84 num = getWidth(obj); 85 } 86 return num; 87 } 88 89 var getTranslate = function(num,direction){ 90 if(direction == 'up' || direction == 'down'){ 91 var i = '0,-' + num + 'px,0'; 92 } else { 93 var i = '-' + num + 'px,0,0'; 94 } 95 return i; 96 } 97 98 var setAnim = function(obj,id,direction,speed){ 99 var num = getNum(obj,direction); 100 if(direction == 'up' || direction == 'down'){ 101 $(obj).parent('.infiniteslide_wrap').css({ 102 height: num + 'px' 103 }); 104 } 105 var i = getTranslate(num,direction); 106 107 $(obj).attr('data-style','infiniteslide' + id); 108 109 var css = '@keyframes infiniteslide' + id + '{' + 110 'from {transform:translate3d(0,0,0);}' + 111 'to {transform:translate3d(' + i + ');}' + 112 '}'; 113 $('<style />').attr('id','infiniteslide' + id + '_style') 114 .html(css) 115 .appendTo('head'); 116 117 if(direction == 'right' || direction == 'down'){ 118 var reverse = ' reverse'; 119 } else { 120 var reverse = ''; 121 } 122 123 $(obj).css({ 124 animation: 'infiniteslide' + id + ' ' + getSpeed(num,speed) + 's linear 0s infinite' + reverse 125 }); 126 } 127 var setStop = function(obj){ 128 $(obj).on('mouseenter',function(){ 129 $(this).css({ 130 animationPlayState: 'paused' 131 }); 132 }).on('mouseleave',function(){ 133 $(this).css({ 134 animationPlayState: 'running' 135 }); 136 }); 137 } 138 139 var setResponsive = function(obj,direction){ 140 var num = getNum(obj,direction); 141 var i = getTranslate(num,direction); 142 return i; 143 }; 144 145 146 147 return this.each(function(key,value){ 148 var $this = $(this); 149 var num = Date.now() + Math.floor(10000*Math.random()).toString(16); 150 if(settings.pauseonhover == true){ 151 setStop($this); 152 } 153 var _onload = function(){ 154 setCss($this,settings.direction); 155 setClone($this,settings.clone); 156 setAnim($this,num,settings.direction,settings.speed); 157 158 if(settings.responsive){ 159 $(window).on('resize',function(){ 160 var i = setResponsive($this,settings.direction); 161 var styleid = $this.attr('data-style'); 162 var stylehtml = $('#' + styleid + '_style').html(); 163 164 var stylehtml_new = stylehtml.replace(/to {transform:translate3d\((.*?)\)/,'to {transform:translate3d(' + i + ')'); 165 $('#' + styleid + '_style').html(stylehtml_new); 166 167 }); 168 } 169 }; 170 171 if (window.loaded) { 172 _onload(); 173 } else { 174 $(window).on('load', _onload); 175 } 176 }); 177 178 } 179 }); 180})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.