Search code examples
javascriptjqueryscrollbindevent-propagation

jQuery stopPropagation - function fire up again


can you tell me how to stop function propagation. I need to fire up some function again after first click action. I using scrollTo jquery plugin for scroll my content and when i click in my 'fire' button content scroll nicely, but i can't do this again... Thx 4 help.

This is my function:

$('.arrow_down').bind('click', function(event){
    $('.recipe_single_view_right_panel').scrollTo({top:'280px', left:'0'}, 800 );
    event.stopPropagation();
});

Solution

  • You will not need to use a big, feature-rich plugin to achieve that.

    All you need to do is to alter the scrollTop - property of the wrapping element. I created a fiddle with a simple example: http://jsfiddle.net/k9bdY/

    The wrapping element is set to overflow: scroll, animating the scrolling-position on click is fairly simple then when using jQuery:

    $('.scroll-btn').on("click", function(e){
        e.preventDefault();
    
        $('#wrapper').animate({
            scrollTop: "+=200px"            
        }, 800);
    });​