![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Soon/BackToTop/view/frontend/web/js/ |
/** * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @author Julien TRAJMAN <[email protected]> <@AgenceSoon> * @copyright Copyright (c) 2018 Agence Soon (http://www.agence-soon.fr) */ define([ 'jquery', 'domReady!' ], function ($) { 'use strict' $.widget('soon.backtotop', { _create: function () { this.jqWindow = $(window) this.jqHtmlBody = $('html, body') /** * Hide by default and check for display */ this.checkBackToTop() this.element.on('click', function (e) { e.preventDefault() this.jqHtmlBody.animate({scrollTop: 0}, 1500, function () { this.destroyScrollListener() }.bind(this)) /** * Break animation prematurely on some scroll related events */ this.jqHtmlBody.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function () { this.jqHtmlBody.stop() this.destroyScrollListener() }.bind(this)) }.bind(this)) this.jqWindow.on('scroll', function () { this.checkBackToTop() }.bind(this)) }, checkBackToTop: function () { if (this.jqWindow.scrollTop() > 100) { this.element.removeClass('fadeout') this.element.addClass('fadein') } else { this.element.removeClass('fadein') this.element.addClass('fadeout') } }, /** * Destroy scroll listener */ destroyScrollListener: function () { this.jqHtmlBody.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove') } }) return $.soon.backtotop })