var commonFunc = commonFunc || {}; ;(function($) { commonFunc = (function() { 'use strict'; return { goTop: function() { var elm, i, l; elm = $('#pageTop'); setDefault(); bindGoTop(); bindScroll(); function bindScroll() { $(window).on('scroll.smbcGoTopBtn', $.debounce(100, function(){ if ($(window).scrollTop() > 200) { elm.css({'-webkit-transform': 'translateY(0px)','transform': 'translateY(0px)'}); } else { elm.css({'-webkit-transform': 'translateY(200px)','transform': 'translateY(200px)'}); } })); } function setDefault(){ elm.attr('href','javascript:;'); var stid = setTimeout(function(){ clearTimeout(stid); elm.css({ '-webkit-transition': 'all 500ms cubic-bezier(.13,.63,.35,1.23)', '-moz-transition': 'all 500ms cubic-bezier(.13,.63,.35,1.23)', '-o-transition': 'all 500ms cubic-bezier(.13,.63,.35,1.23)', 'transition': 'all 500ms cubic-bezier(.13,.63,.35,1.23)' }, 0) }); elm.css({ '-webkit-transform': 'translateY(200px)', 'transform': 'translateY(200px)', 'display': 'block' }); } function bindGoTop(){ elm.on('click.smbcGoTopBtn touchend.smbcGoTopBtn', function(){ elm.css({'-webkit-transform': 'translateY(0px)','transform': 'translateY(0px)'}); var p = $('#top').offset().top; $('html, body').stop().animate({ scrollTop : p }, 500, 'easeOutExpo'); return false; }) } } } }()); $(function() { commonFunc.goTop(); }); })(jQuery);