Advertisement
artemsemkin

Rhye: handle anchor links outside of main container [event delegation]

Apr 27th, 2022
1,590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery('#kotwicamenu').on('click', 'a[href*="#"]:not([href="#"]):not([href*="#elementor-action"])', function (event) {
  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.       event.preventDefault();
  12.       window.rhye.components.Scroll.scrollTo({
  13.         x: 0,
  14.         y: $el.offset().top,
  15.         duration: 800,
  16.         easing: (pos) => window.rhye.components.Scroll.getEasingScroll(pos)
  17.       });
  18.     }
  19.   }
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement