Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

about scrollDirection and exiting overflow-y div inside #31

Closed
chrisvidal opened this issue Jan 25, 2021 · 4 comments
Closed

about scrollDirection and exiting overflow-y div inside #31

chrisvidal opened this issue Jan 25, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@chrisvidal
Copy link

Hi,
thanks for this light scroll library.
I was wondering how to get the scrollDireciton, to manipulate the header visibility in my case.
Also, I have a div with an overflow-y that does not work anymore when I enable the scroll, is this a bug or expected?
how to handle this case in your opinions?

thanks

@ashthornton
Copy link
Owner

Hi @chrisvidal , you could get the scroll direction like so:

let previousScrollPos = 0

ASScroll.on('scroll', scrollPos => {
    if (scrollPos > previousScrollPos) {
        // scrolled up
    } else {
        // scrolled down
    }
    previousScrollPos = scrollPos
})

Could you show me an example of your overflow issue? Using Codepen or similar.

@chrisvidal
Copy link
Author

Thanks @ashthornton

here a quick codepen illustrating the issue

https://codepen.io/chrislabz/pen/qBqOqaP

@ashthornton ashthornton self-assigned this Feb 6, 2021
@ashthornton ashthornton added the bug Something isn't working label Feb 6, 2021
@ashthornton
Copy link
Owner

Note: related to #24

@ashthornton
Copy link
Owner

ashthornton commented Feb 22, 2021

@chrisvidal I've added the ability to add a class to an element (like your overflow element) that will prevent ASScroll from scrolling the page. It's available in the latest version (1.7.5 - 69ecd83).

The default class to add is .asscroll-block but you can change this in the configuration options.

It essentially adds an event to the element which stops the wheel event from propagating. I wanted a seamless way of doing this without getting the user to add classes but the alternatives aren't efficient enough.

Please let me know if this works for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants