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 all commits
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
5 changes: 5 additions & 0 deletions 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 @@ -605,6 +606,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 +822,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,12 +903,14 @@ 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();
e.stopPropagation();

removeClasses(this.el, this.classNames.dragging);
this.onStopScrolling();

elDocument.removeEventListener('mousemove', this.drag, true);
elDocument.removeEventListener('mouseup', this.onEndDrag, true);
Expand Down