-
"smooth-scrollbar": "^8.2.4" Again, awesome scroll 👍 Hi, maybe is a silly question, but i didn't find a method to block the scroll on the page ( without destroy it ) like for example if
Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 17 replies
-
You can use plugin system to do this: import Scrollbar, { ScrollbarPlugin } from 'smooth-scrollbar';
class ModalPlugin extends ScrollbarPlugin {
static pluginName = 'modal';
static defaultOptions = {
open: false,
};
transformDelta(delta) {
return this.options.open ? { x: 0, y: 0 } : delta;
}
}
Scrollbar.use(ModalPlugin, /* OverscrollPlugin */);
// usage
const scrollbar = Scrollbar.init(elem);
onModalOpen -> scrollbar.updatePluginOptions('modal', { open: true });
onModalClose -> scrollbar.updatePluginOptions('modal', { open: false }); |
Beta Was this translation helpful? Give feedback.
-
Brilliant, way better than my approach ! 🎉 |
Beta Was this translation helpful? Give feedback.
-
It's so cool, Thanks. |
Beta Was this translation helpful? Give feedback.
-
thank you |
Beta Was this translation helpful? Give feedback.
-
@idiotWu hi how |
Beta Was this translation helpful? Give feedback.
-
I have same problem, where I use dropdown as modal on desktop resolutions. I noticed if you create modal outside of main smooth scroll wrapper and initalize modal smooth scroll, you wont be able to scroll main scroll as long as mouse is over modal. So, if you have modal over whole screen (or modal backdrop), everything should work as expected, without disabling or destroying any smooth scrollbar. So, I think best partice would be, if you have more than one smooth scrollbar wrappers, you should place each outside of it. |
Beta Was this translation helpful? Give feedback.
-
@robizzt
but when you have I test everything coz I needed to header and menu outside of wrapper and at last I find no solution for it this.scrollbar.track.yAxis.element.style.display = "none" |
Beta Was this translation helpful? Give feedback.
-
I decided to go with |
Beta Was this translation helpful? Give feedback.
-
How can I implement the same in JQuery, please help me. |
Beta Was this translation helpful? Give feedback.
-
@idiotWu , Thank you for amazing library! For example: Do I miss something, or should i use another workaround for my task? Thank you for reply! |
Beta Was this translation helpful? Give feedback.
-
I changed the code of the plugin itself a bit. I know this is not entirely correct. But no other idea came to mind. This is for desktop:
This is for mobile: i(r, "touchmove", function (e) {
|
Beta Was this translation helpful? Give feedback.
You can use plugin system to do this: