/* ------------------------------------------- * @constructor ------------------------------------------- */ var u = new EPOS_CARD.Util(); // u インスタンスを作成 /* ------------------------------------------- * @init ------------------------------------------- */ j$(function(){ j$.floatingControl(); }); /* ------------------------------------------- * @plugin ------------------------------------------- */ (function(j$){ var u = new EPOS_CARD.Util(); // u インスタンスを作成 /* * @method floating */ j$.floatingControl = function (){ // vars var u = new EPOS_CARD.Util() var $elm = j$('.js-floatingWrap'), $pageContainer = j$("#pageContainer"), slideInSpeed = 500, slideStatus = 'slideActive', negative = $elm.innerHeight() + 20; if($elm.length === 0){ return false; } // setting $elm.css("bottom", "-" + negative + "px"); // trigger u.$win.on("load", function(){ $pageContainer.css("padding-bottom", $elm.innerHeight() + 10); var top = u.$win.scrollTop(); if(top != 0){ $elm.show(); $elm.addClass(slideStatus); $elm.stop().animate({ "bottom": 0 },slideInSpeed, function() { $elm.removeClass(slideStatus); }); } }); u.$win.on("scroll", function(){ var top = u.$win.scrollTop(); if(top === 0){ $elm.addClass(slideStatus); $elm.stop().animate({ "bottom": "-" + negative + "px" },slideInSpeed, function() { $elm.removeClass(slideStatus); }); } else if (top != 0 && !$elm.hasClass(slideStatus)) { $elm.show(); $elm.addClass(slideStatus); $elm.stop().animate({ "bottom": 0 }, slideInSpeed, function() { $elm.removeClass(slideStatus); }); } }); } })(jQuery);