![]() 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/design/frontend/Cnc/default/Magento_Theme/web/js/ |
/** * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @author Benoit Alix <[email protected]> * @copyright Copyright (c) 2019 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com/) */ define([ "jquery", "tools" ], function ($, tools) { "use strict"; /** * This widget allows to add animated scroll to target element on link click * This widget is a Jade Front-end feature * * Your target ID must correspond to the href value of your link element * Your links must have a ul li parent structure */ $.widget('jfe.scrollTo', { options: { linksElement: '[data-role=links]', animateDuration: 500, stickyHeader: false }, /** * @private */ _create: function () { this.linksHandler(); }, /** * Links handler */ linksHandler: function () { var self = this; $(this.options.linksElement).find('a').on('click', function(event){ if (this.hash !== "") { event.preventDefault(); self.hash = this.hash; var selectedLink = $(this).attr('href'); self.linksToggleClass($(this)); self.scrollToTarget(selectedLink); } }); }, /** * Toggle links current class * @param {Object} el */ linksToggleClass: function(el) { var navigationItems = $(this.options.linksElement).find('ul li'); navigationItems.removeClass('current'); el.parent().addClass('current'); }, /** * Animate window scroll to target * @param {Object} target */ scrollToTarget: function(target){ var self = this; var headerHeight = $('.page-header').innerHeight() + 20; var targetPosition = self.options.stickyHeader ? $(target).offset().top - headerHeight: $(target).offset().top; $('html, body').animate({ scrollTop: targetPosition }, self.options.animateDuration, function(){ self.updateHashUrl(targetPosition); }); }, /** * Update browser hash */ updateHashUrl: function(targetPosition){ window.location.hash = this.hash; $('html, body').scrollTop(targetPosition); } }); return $.jfe.scrollTo; });