matometaru
9/29/2017 - 6:21 AM

無限スライダー固定幅

function logoLoop() {
	const $companyLogos = $('#js-company');
	const slideSpeed = 1000;
	// resize未対応
	$companyLogos.each(function(){
		const self = $(this),
		selfWidth = self.innerWidth(),
		ul = self.find('ul'),
		li = self.find('li'),
		listWidth = li.outerWidth(true),
		listCount = li.length,
		loopWidth = listWidth * listCount;

		ul.wrapAll('<div class="loopSliderWrap" />');
		const $selfWrap = self.find('.loopSliderWrap');

		let flag = 1;
		if( flag ){
			ul.css({width:loopWidth}).clone().appendTo($selfWrap);
			ul.css({width:loopWidth}).clone().appendTo($selfWrap);
			$selfWrap.css({width:loopWidth*3});

			function loopMove(){
				TweenLite.to($selfWrap, 2 * listCount, {
					x:-loopWidth,
					ease: Power0.easeNone,
					onComplete: function() {
						loopMove();
						TweenLite.to($selfWrap, 0, {x:0});
					}
				});
			};
			loopMove();
			flag = 0;
		}
	});
}
logoLoop();