/********************************************* * invoice.js * ------------------------------------------- * @init * @plugin *********************************************/ /* ------------------------------------------- * @noConflict ------------------------------------------- */ jqNew = jQuery.noConflict(); if($ === undefined){ $ = jQuery; } j$ = jQuery || jqNew; /* ------------------------------------------- * @init ------------------------------------------- */ j$(function(){ var u = new EPOS_CARD.Util(); j$.enterTheScreen(); j$(window).on('load', function(){ j$.slider(); }) }); /* ------------------------------------------- * @plugin ------------------------------------------- */ (function(j$){ var u = new EPOS_CARD.Util(); // u インスタンスを作成 j$.slider = function(config){ var c = $.extend({ sliderName: ".js-slider01" }, config); var $elm = $(c.sliderName); if($elm.length === 0){ return false; } var stayAutoPlay = function(sliderName){ var t = $(sliderName).offset().top; var p = t - $(window).height(); $(window).on('scroll load',function(){ if($(window).scrollTop() > p && !$(sliderName).hasClass('play')){ $(sliderName).slick('slickPlay'); $(sliderName).addClass('play'); } }); } $elm.each(function(){ var $this = $(this); $this.slick({ autoplay: false, variableWidth: true, slidesToScroll: 1, slidesToShow: 3, centerMode: (u.isRangeSP())? true : false, centerPadding: '0px', autoplaySpeed: 4200, speed: 400, dots: true, dotsClass: 'top-sliderNums slick-dots', }); stayAutoPlay($this); }); }; j$.enterTheScreen = function(){ var elem = j$('.js-enterTheScreen'), isAnimate = 'isAnimate', wh = j$(window).height(), doch, bottom; if(elem.length === 0){ return false} function entry(){ elem.each(function () { var elemOffset = j$(this).offset().top; var scrollPos = j$(window).scrollTop(); if(scrollPos > elemOffset - wh + (wh / 4) ){ j$(this).addClass(isAnimate); } if(bottom <= j$(window).scrollTop()){ $(this).addClass(isAnimate); } }); } j$(window).on('load', function (){ doch = j$(document).innerHeight(); bottom = doch - wh; entry(); }); j$(window).on('scroll', function (){ entry() }); } })(jQuery);