Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with smooth scrolling libraries #10

Open
nurpais opened this issue Aug 18, 2022 · 6 comments
Open

Using with smooth scrolling libraries #10

nurpais opened this issue Aug 18, 2022 · 6 comments
Labels
question Further information is requested

Comments

@nurpais
Copy link

nurpais commented Aug 18, 2022

Hello! it's an amazing library.

I have some issues when working with safari. If I hover the cursor over an image, text appears or when I hover over links or buttons, the cursor decreases. The problem is that if I scroll down, the cursor remains in the same state. Everything works fine in google chrome. Maybe I missed something.

@nurpais
Copy link
Author

nurpais commented Aug 18, 2022

Screen.Recording.2022-08-19.at.3.12.31.AM.mov

@Drafteed
Copy link
Collaborator

Drafteed commented Aug 19, 2022

Thanks! Is the smooth scrolling library using on your page?

@nurpais
Copy link
Author

nurpais commented Aug 19, 2022

Yes, I am using the locomotive-scroll library.

@Drafteed
Copy link
Collaborator

Drafteed commented Aug 22, 2022

Using smooth scrolling libraries leads to this result, since the browser does not recalculate (on custom scrolling) mouseenter/mouseleave events, css hovers, etc.

The only suggestion I can make is to try and force a reflow/redraw at the end of the scroll to force the browser recalculate the "hover events".

Example (need tune):

import LocomotiveScroll from 'locomotive-scroll';
import debounce from 'lodash-es/debounce';

const scroll = new LocomotiveScroll({
    el: document.querySelector('[data-scroll-container]'),
    smooth: true
});

const reflow = () => {
    const el = document.querySelector('.c-scrollbar'); // some visible element on page
    el.style.display = 'none';
    for(let i = 0; i < 3; i++) el.offsetHeight;
    el.style.display = 'block';
};

const reflowDebounced = debounce(reflow, 50);

scroll.on('scroll', () => {
    reflowDebounced();
});

@Drafteed Drafteed changed the title Safari scroll issues Using with smooth scrolling libraries Aug 22, 2022
@Drafteed Drafteed added the question Further information is requested label Aug 22, 2022
@nurpais
Copy link
Author

nurpais commented Aug 23, 2022

Thank you @Drafteed, I will try and let you know.

@samholguin
Copy link

This solution isn't working for me, unfortunately.

I'm using the Lenis library [https://github.com/studio-freight/lenis].

When the cursor hides after morphing to text mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants