• Resolved Solitweb

    (@solitweb)


    Is it possible to add smooth scroll when linking to a Menu Anchor Widget on a One Page Website?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Same issue, have you solved?

    Thread Starter Solitweb

    (@solitweb)

    I’m working on it! When it’s ready I contribute to the plugin.

    Thread Starter Solitweb

    (@solitweb)

    Smooth scroll will be enabled if this can be changed (/assets/js/make-column-clickable.js)

    
    jQuery( function( $ ) {
      $( 'body:not(.elementor-editor-active) .make-column-clickable-elementor' ).click( function( event ) {
        if ( ! $( this ).data( 'column-clickable' ).length ) {
          return;
        }
    
        if( $( this ).data( 'column-clickable' ).charAt(0) != "#" ) {
          window.open( $( this ).data( 'column-clickable' ), $( this ).data( 'column-clickable-blank' ) );
          return false;
        }
    
        var clickedLink = $( this ).data( 'column-clickable' ),
          $anchor;
    
        try {
          $anchor = jQuery( clickedLink ).filter( '.elementor-element, .elementor-menu-anchor' );
        } catch ( e ) {
          return;
        }
    
        if ( ! $anchor.length ) {
          return;
        }
    
        var scrollTop = $anchor.offset().top,
          $wpAdminBar = elementorFrontend.elements.$wpAdminBar,
          $activeStickies = jQuery( '.elementor-section.elementor-sticky--active' ),
          maxStickyHeight = 0;
    
        if ( $wpAdminBar.length > 0 ) {
          scrollTop -= $wpAdminBar.height();
        }
    
        // Offset height of tallest sticky
        if ( $activeStickies.length > 0 ) {
          maxStickyHeight = Math.max.apply( null, $activeStickies.map( function() {
            return jQuery( this ).outerHeight();
          } ).get() );
    
          scrollTop -= maxStickyHeight;
        }
    
        $( 'html, body' ).animate( {
          scrollTop: scrollTop,
        }, 500, 'linear' );
    
        return false;
      });
    });
    

    I used code from Elementor as an example.

    Plugin Author Fernando Acosta

    (@amgnando)

    Hi guys!

    I’ll take a look on it for the next version.

    Thanks!

    Plugin Author Fernando Acosta

    (@amgnando)

    Hi, @solitweb! Thanks for help me!

    I’ve added the feature for smooth scroll.

    Thread Starter Solitweb

    (@solitweb)

    Hi @amgnando, my pleasure! Happy to help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Smooth scroll’ is closed to new replies.