Comments (2)
I have the same problem! This issue definitely needs a fix
Upd
Just looked into the code and it seems like I have a problem of another kind but it looks similar. I'm trying to use drag-and-drop handler together with scrollbooster. I have shouldScroll function defined like this:
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 state.isDragging
is always true on single click because of this line in scrollboster:
this.events.pointerdown = (event) => {
// ....
this.isDragging = true
}
I'm going to investigate further
Upd2
I think I've found the problem:
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
statement:
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
from scrollbooster.
Upd2 I think I've found the problem:
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
statement: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.
from scrollbooster.
Related Issues (20)
- Won't run smoothly with the inspector open
- Consider clarifying that bounce works only in scrollMode: 'transform'
- How to disable scrolling when clicking on child block?
- Possible to let scrollTo use translate3d in stead of translate
- How to make header fixed when scrolled to top of the browser?
- event.touches is undefined HOT 1
- Doesn't work horizontal scrolling on mousewheel
- Cannot drag elements
- Drag to scrool whole website HOT 1
- Editable field
- Unable to test component using Scrollbooster
- How to get scroll position to use in slider navigation HOT 1
- This is not an issue but a suggestion.
- Can not swiping up the page if pointer over the viewport HOT 3
- onPointerDown/onPointerUp options not working
- CSS scroll-behavior: smooth; breaks native mode
- Button inside scrollable area unclickable after doing scroll HOT 1
- Text Selection on phone does not allow mobile users to click on navigation items
- IF DOESN'T WORK FOR YOU, READ THIS!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrollbooster.