igorskyflyer / npm-scrollend-polyfill

πŸ›΄ A performant and light (< 1.5KB) JavaScript polyfill for the scrollend Event. ⛸️
https://www.npmjs.com/package/@igor.dvlpr/scrollend-polyfill
MIT License
4 stars 0 forks source link

How to use it with import #1

Closed Colir closed 2 months ago

Colir commented 2 months ago

Hi, i think I'm dummy, but I can't figure how the polyfill works.

here is my code

` import scrollend from 'scrollend-polyfill';

export default function(){

window.addEventListener('click', (e) => {
    if( e.target.classList.contains('preventStickyNavShow') ){
        cancelStickyNavShow = true;
        document.addEventListener("scrollend", (evt) => {
                console.log("done scrolling");
                cancelStickyNavShow = false;
            },{ once: true });

    }  
})

} ` But this has no effect in Safari (this browser doesn't support the native scrollend event) I've also tried window.addEventListener('scrollend') without success.

I'm missing out on how to init the polyfill.

Can you help me. Thank you

igorskyflyer commented 2 months ago

Hello @Colir, thank you for taking an interest in using my scrollend polyfill.

In order to provide you with some tips and fix(es), could you please provide me with the full source code of the page using it or a repository so I can pinpoint the exact issue.

Thanks. 😁

Colir commented 2 months ago

Hi @igorskyflyer , Sorry, I found the problem: the import must be done with import scrollend from '@igor.dvlpr/scrollend-polyfill'; and not import scrollend from 'scrollend-polyfill'; Everything's working fine now, thanks.

igorskyflyer commented 2 months ago

Hi @igorskyflyer , Sorry, I found the problem: the import must be done with import scrollend from '@igor.dvlpr/scrollend-polyfill'; and not import scrollend from 'scrollend-polyfill'; Everything's working fine now, thanks.

Got it, yes, there are multiple ways of importing the polyfill depending on your environment's setup and workflow. I just wanted to check everything. Glad you figured it out yourself, nice work. 😁

And thanks for confirming that it works properly in Safari, I have done only limited tests in it.

If the issue is resolved we can close it now and if you have any other issue(s), don't hesitate to open a new issue.