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

Do not hide scrollbar if the mouse is being dragged and not yet released. #684

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/simplebar-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class SimpleBarCore {
stopScrollDelay = 175;
isScrolling = false;
isMouseEntering = false;
isDragging = false;
scrollXTicking = false;
scrollYTicking = false;
wrapperEl: HTMLElement | null = null;
Expand Down Expand Up @@ -370,7 +371,9 @@ export default class SimpleBarCore {
this.el.addEventListener('mousemove', this.onMouseMove);
this.el.addEventListener('mouseleave', this.onMouseLeave);

this.contentWrapperEl?.addEventListener('scroll', this.onScroll);
this.contentWrapperEl?.addEventListener('scroll', this.onScroll, {
passive: true
thomasdao marked this conversation as resolved.
Show resolved Hide resolved
});

// Browser zoom triggers a window resize
elWindow.addEventListener('resize', this.onWindowResize);
Expand Down Expand Up @@ -605,6 +608,7 @@ export default class SimpleBarCore {
}

hideScrollbar(axis: Axis = 'y') {
if (this.isDragging) return
if (this.axis[axis].isOverflowing && this.axis[axis].scrollbar.isVisible) {
removeClasses(this.axis[axis].scrollbar.el, this.classNames.visible);
this.axis[axis].scrollbar.isVisible = false;
Expand Down Expand Up @@ -820,6 +824,7 @@ export default class SimpleBarCore {
* on scrollbar handle drag movement starts
*/
onDragStart(e: any, axis: Axis = 'y') {
this.isDragging = true
const elDocument = getElementDocument(this.el);
const elWindow = getElementWindow(this.el);
const scrollbar = this.axis[axis].scrollbar;
Expand Down Expand Up @@ -900,6 +905,7 @@ export default class SimpleBarCore {
* End scroll handle drag
*/
onEndDrag = (e: any) => {
this.isDragging = false
const elDocument = getElementDocument(this.el);
const elWindow = getElementWindow(this.el);
e.preventDefault();
Expand Down