Aritra Hazra
Aritra Hazra

Reputation: 65

Detecting jQuery scroll event from inside mousewheel event

$(".elem").on("wheel mousewheel", function(){
    // if( $(this).scrollHappens ){
    //     do something
    // } else {
    //     do something else
    // }
    //
    // how to do this?
});

I'm making a fullscreen vertical content slider, which slides on mousewheel event. now, each slide might have scrollable content. in that case i don't want the silder to slide unless user has reached the bottom or top of the scrollable content (when scroll won't fire).

Or is there are any better way to do this?

Upvotes: 2

Views: 833

Answers (1)

simey.me
simey.me

Reputation: 2207

Use event.target to detect if you're inside the scrolling panel, if true, then use .scrollTop() with the heights of the scrolling panels, along with the direction of scroll to detect if you're at the bottom or the top.

Here's a JSFiddle to demonstrate: https://jsfiddle.net/g6e4fj97/2/

Upvotes: 3

Related Questions