idiotWu / smooth-scrollbar

Customizable, Extendable, and High-Performance JavaScript-Based Scrollbar Solution.
https://idiotwu.github.io/smooth-scrollbar/
MIT License
3.32k stars 383 forks source link

Horizontal Scroll even after Disable X-Axis Scrolling #481

Open idiotWu opened 2 years ago

idiotWu commented 2 years ago

Discussed in https://github.com/idiotWu/smooth-scrollbar/discussions/480

Originally posted by **blitzve0** June 4, 2022 https://user-images.githubusercontent.com/67477131/171929609-cdce99fa-e567-408e-8621-3e6c7e1b7ee8.mp4 Hi, I am using a plugin to disable X-axis horizontal scrolling totally, but sometimes accidentally when I hold and drag from the right edge, the site starts horizontally dragging. You can check the video and can try it out also here https://haspr.in/ This is the Plugin ``` import Scrollbar from 'smooth-scrollbar' class DisableScroll extends Scrollbar.ScrollbarPlugin { static pluginName = 'DisableScroll' transformDelta(delta, fromEvent) { delta['x'] = 0 return delta } } DisableScroll.pluginName = 'DisableScroll' export default DisableScroll ```
RubenReuring commented 2 years ago

Got the same issue here. Any idea how to quick fix or when an update will be comming?

idiotWu commented 2 years ago

@RubenReuring a quick and dirty fix that eliminates horizontal scrolling:

import { Scrollbar } from 'smooth-scrollbar/scrollbar'; // NOTICE: not the default entry

const setMomentum = Scrollbar.prototype.setMomentum;

Scrollbar.prototype.setMomentum = function(x, y) {
    setMomentum.call(this, 0, y);
}
sadeghbarati commented 1 year ago

https://github.com/idiotWu/smooth-scrollbar/discussions/511#discussioncomment-4666446

Temporary workaround

scrollbar.limit.x = 0

https://stackblitz.com/~/github.com/Cuberto/scroll-sequence-demo

once all dependencies installed open terminal ctrl + `

and run gulp command to start the server