Giter Club home page Giter Club logo

Comments (6)

errnoenomem avatar errnoenomem commented on August 13, 2024 2

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.

pumpknhd avatar pumpknhd commented on August 13, 2024 2

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.

Bernardo-Castilho avatar Bernardo-Castilho commented on August 13, 2024

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.

Bernardo-Castilho avatar Bernardo-Castilho commented on August 13, 2024

Nice! Thanks for sharing this solution!

from dragdroptouch.

koz1ma avatar koz1ma commented on August 13, 2024

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.

welkinwong avatar welkinwong commented on August 13, 2024

我实际上可以通过更改2行代码来使其工作。

我刚刚从d.addEventListener('touchstart',ts,opt);中删除了opt参数;并注释掉了preventDefault()(第188行)。将pressholdmode = true设置为有效

it works!👍

from dragdroptouch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.