Advertisement
artemsemkin

Rhye: handle anchor links outside of main container

Apr 27th, 2022
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery('#kotwicamenu a[href*="#"]:not([href="#"]):not([href*="#elementor-action"])').each(function () {
  2.   const
  3.     $current = jQuery(this),
  4.     url = $current.attr('href'),
  5.     filteredUrl = url.substring(url.indexOf('#'));
  6.  
  7.   if (filteredUrl.length) {
  8.     const $el = jQuery(filteredUrl);
  9.  
  10.     if ($el.length) {
  11.       $current.on('click', function (e) {
  12.         e.preventDefault();
  13.         window.rhye.components.Scroll.scrollTo({
  14.           x: 0,
  15.           y: $el.offset().top,
  16.           duration: 800,
  17.           easing: (pos) => window.rhye.components.Scroll.getEasingScroll(pos)
  18.         });
  19.       });
  20.     }
  21.   }
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement