-
Notifications
You must be signed in to change notification settings - Fork 80
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
'isDragging' is incorrectly read as true when querying via 'getState()' #54
Comments
I have the same problem! This issue definitely needs a fix Upd new ScrollBooster({
viewport: containerRef.current,
content: contentRef.current,
scrollMode: 'native',
direction: 'horizontal',
textSelection: true,
shouldScroll: (state, event) => {
const isDragHandleToched = event.path.some(checkIsDragHandle)
return !isDragHandleToched
},
}) But it disables click handlers on a draggable element after a first scroll move with scrollbooster. And this.events.pointerdown = (event) => {
// ....
this.isDragging = true
} I'm going to investigate further Upd2 this.events.click = (event) => {
const state = this.getState()
const dragOffsetX = this.props.direction !== 'vertical' ? state.dragOffset.x : 0
const dragOffsetY = this.props.direction !== 'horizontal' ? state.dragOffset.y : 0
if (Math.max(Math.abs(dragOffsetX), Math.abs(dragOffsetY)) > CLICK_EVENT_THRESHOLD_PX) {
// this is always true if you have scrolled to any amount of pixels more than 5
// ...even if this.isDragging equals false
event.preventDefault()
event.stopPropagation()
}
this.props.onClick(state, event, isTouch)
} My solution is to add this.isDragging to the if (this.isDragging && Math.max(Math.abs(dragOffsetX), Math.abs(dragOffsetY)) > CLICK_EVENT_THRESHOLD_PX) {
event.preventDefault()
event.stopPropagation()
} I didn't dig in enough to say it should be patched on the main branch or if it going to work in your case, but it worked for me |
Not sure this project is getting updated but this solution worked for my project as well. |
Hi, first of all thanks for the great library.
I'm currently having an issue where
isDragging
state is set to true but shouldn't be. This is reproducible when completing a mouse drag in the scrollable area then querying the state without clicking in the scrollable area again.It seems to be to do with how we determine
isDragging
state ingetState()
.Instead of using
this.isDragging
which is set to false onmouseup
it relys ondragOffset
which doesn't seem to be reset until another pointer event occurs.Couldn't find any other issues relating to this so I am wondering if I am missing something?
Thanks in advance :)
The text was updated successfully, but these errors were encountered: