GianlucaGuarini / Tocca.js

Super lightweight script (~1kb) to detect via Javascript events like 'tap' 'dbltap' 'swipeup' 'swipedown' 'swipeleft' 'swiperight' on any kind of device.
http://gianlucaguarini.github.io/Tocca.js/
MIT License
660 stars 60 forks source link

Question : how to use Tocca in a js file with 'import' #66

Closed Aarbel closed 4 years ago

Aarbel commented 4 years ago

For example in a React File, does the simple import is enough to make it work ? Thanks a lot for your help !

import tocca from 'tocca';

class MyComponent extends React.Component  {
     componentDidMount() {
      const element = document.getElementById("my_target")
      element.addEventListener('tap',function(e){
          console.log("Element tapped")
      });
    }

     render() {
       <div id="my_target">
          TARGET
       </div>

    }
}
GianlucaGuarini commented 4 years ago
import 'tocca';

should be enough.