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

CSS scroll-behavior: smooth; breaks native mode #80

Open
interactiveRob opened this issue Jul 21, 2021 · 0 comments
Open

CSS scroll-behavior: smooth; breaks native mode #80

interactiveRob opened this issue Jul 21, 2021 · 0 comments

Comments

@interactiveRob
Copy link

Simple implementation below.

I have scroll-behavior: smooth; on my viewport element, that causes it to scroll very slowly and sometimes freeze like it's trying to calculate what to do. Removing this CSS property entirely allowed the plugin to scroll the div smoothly as desired.

Fix: You should mention this in the documentation.

My implementation--

`import ScrollBooster from 'scrollbooster';

let DragScroll = (({}) => {
class DragScroll {
constructor(node) {
this.node = node;
this.content = this.node.querySelector([data-js="scroll-content"]);
this.nodeExists = exists(this.node);
if (!this.nodeExists) return;
}

    initPlugin() {
        let sb = new ScrollBooster({
            viewport: this.node,
            content: this.content,
            scrollMode: 'native',
            direction: 'vertical',
            pointerMode: 'mouse',
        });
    }

    init() {
        if (!this.nodeExists) return;
        this.initPlugin();
    }
}

return {
    init({ selector }) {
        let nodeList = document.querySelectorAll(selector);

        if (!nodeList.length) return;

        return [...nodeList].map((node) => {
            let module = new DragScroll(node);
            module.init();

            return module;
        });
    },
};

})(window);

export default Object.create(DragScroll);
`

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

No branches or pull requests

1 participant