Comments (6)
I was actually able to get it working by changing 2 lines of code.
I just removed the opt argument from d.addEventListener('touchstart', ts, opt); and commented out a preventDefault() (line 188). turn pressholdmode = true and it works
from dragdroptouch.
Works! Requires:
- d.addEventListener('touchstart', ts, opt) -> d.addEventListener('touchstart', ts)
- d.addEventListener('touchmove', tm, opt) -> d.addEventListener('touchmove', tm, {passive: false})
- commented out a preventDefault() (line 188)
- turn pressholdmode = true
I also had to add the following CSS when on iOS so that texts are not selected when dragging.
.disableSelect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
Here's what I used to detect if it's iOS:
(/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1))
from dragdroptouch.
I suspect this might be possible somehow, but I don't know how to do it.
The problem is that you have to decide whether to handle the touchstart event as soon as it happens. If you keep the event, the built-in scrolling won't start and you can't change your mind and turn it on later. If you don't keep the event, then scrolling will start and you can't stop it and start dragging later.
I suppose you could emulate scrolling by changing the document body's scrollLeft/scrollTop values, but that would be really hacky and not as fluid/efficient as the build-in scrolling.
from dragdroptouch.
Nice! Thanks for sharing this solution!
from dragdroptouch.
The scrolling was still happening when i had used this polyfill so i fixed by adding passive:false to the touchmove event like:
d.addEventListener('touchmove', tm, {passive: false});
from dragdroptouch.
我实际上可以通过更改2行代码来使其工作。
我刚刚从d.addEventListener('touchstart',ts,opt);中删除了opt参数;并注释掉了preventDefault()(第188行)。将pressholdmode = true设置为有效
it works!👍
from dragdroptouch.
Related Issues (20)
- Drag-Drop-Touch-Polyfill not working with React Grid Layout library HOT 5
- NPM package outdated HOT 3
- Image is not draggable on Canvas. HOT 7
- Script breaks with this code HOT 2
- The returned event does not have offsetX and offsetY property HOT 5
- dblclick event triggered twice on touch screens HOT 1
- Internal selections is not working HOT 9
- How to drag&drop from window A to window B in Android? HOT 10
- Breaks Bootstrap 3 dropdown menu HOT 2
- Is it possible to make this a default behaviour on desktop as well?
- Enabling the polyfill only when draggable attribute is set HOT 1
- Demo page doesn't work, and uses a "dead" copy of wijmo
- Contributing changes HOT 8
- update the npm package HOT 3
- Set up github pages for the master branch HOT 10
- Playwright install in postinstall HOT 2
- Refine the demo page
- Should not start touch-dragging when source element has draggable="false" HOT 8
- tried to tweak the `options` of your new version, not working though HOT 30
- add DEBUG to the source HOT 4
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 dragdroptouch.