Jump to content
Search Community

GSQP Draggable get scrollTop position on scroll event

Alexis_G test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I use the Draggable plugin locked on the y axis to manage scrolling in a section. I would like to retrieve the y position of the scrolled element to trigger an event when reaching the end of the scroll area. It's working as follow when the user drag but not when he use the mouse wheel for ex.

 

Draggable.create(Pr, {
  type: 'scrollTop',
  ...
  onDrag: function(e) {
    type: 'scrollTop',
    this.update()
    console.log(this.y)
  }
})

 

How can I get a unified way to retrieve the y position between the different events, drag, scroll, etc.

Link to comment
Share on other sites

Hm, a codepen would really help (just the absolute basic setup). Your code looks a bit odd to me (like the type:"scrollTop" inside your onDrag function, and I don't know why you're calling update() in there either). Draggable itself is for dragging - it doesn't track mousewheel interactions. It seems to me like you'd need to add your own listeners accordingly and snag the scrollTop in those events. But again, if you need some more help, just post a codepen demo and we'd be glad to take a peek. 

 

Happy tweening!

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...