• Resolved koendelbroek

    (@koendelbroek)


    Hi, I have a question about a script/code created by or shared by a certain Ben here on the forum.

    I want the accordion topic you open to be at the top of the screen because that way, you don’t have to scroll al the way back up if you open the second one and so on..

    It works great but because I use a header-plugin that makes the header sticky, the accordion just positions itself under the header.
    When I deactivate the plugin (sticky header) it works just fine.

    Is there a way to add something like “100px from top” to the code?
    I don’t understand a thing about coding so I would not know if it’s possible or where and how to put it in..

    Thank you very much!

    <script>
    jQuery( document ).ready( function( $ ) {
    $( ‘.elementor-tab-title’ ).click( function( ) {
    var pane = $(this);
    setTimeout(function(){
    var $panel = pane.closest(‘.elementor-accordion-item’);
    $(‘html,body’).animate({
    scrollTop: $panel.offset().top
    }, 500);
    }, 500 );
    });
    });
    </script>

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • You should be able to minus the header height, something like so:

    jQuery( document ).ready( function( $ ) {
    	$( '.elementor-tab-title' ).click( function() {
    		var pane = $(this);
    		setTimeout( function(){
    			var $panel = pane.closest( '.elementor-accordion-item' );
    			$( 'html,body' ).animate( {
    				scrollTop: $panel.offset().top - $( '#site-header' ).outerHeight()
    			}, 500);
    		}, 500 );
    	} );
    } );
    Thread Starter koendelbroek

    (@koendelbroek)

    Hi thank you for your reply, but unfortunately it does not work.
    De script doesn’t work at all in this form.

    It doesn’t have to detect the header-height, just 100 pixels down is enough.
    The header is 74 pixels.

    Thread Starter koendelbroek

    (@koendelbroek)

    Correction! It DOES work!

    Thank you a lot! Apparently, I had to refresh my page somehow.

    Thank you a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Code-snippet problem for accordion’ is closed to new replies.