Finger

移动端手势事件识别。

→ Touch Me

Usage

  1. import 'omim/finger'
  2. import { render, h, tag, WeElement } from 'omi'
  3. @tag('my-app')
  4. class MyApp extends WeElement {
  5. handleTap = (evt) => {
  6. this.wording += '\r\nTap'
  7. this.update()
  8. }
  9. handleSwipe = (evt) => {
  10. this.wording += '\r\nSwipe-' + evt.detail.direction
  11. this.update()
  12. }
  13. render() {
  14. return (
  15. <div id='app'>
  16. <m-finger onTap={this.handleTap} onSwipe={this.handleSwipe}>
  17. <div class="touchArea">
  18. {this.wording}
  19. </div>
  20. </m-finger>
  21. </div>
  22. )
  23. }
  24. }
  25. render(<my-app />, 'body')

API

Props

  1. {
  2. onTouchStart: function () { },
  3. TouchMove: function () { },
  4. TouchEnd: function () { },
  5. TouchCancel: function () { },
  6. MultipointStart: function () { },
  7. MultipointEnd: function () { },
  8. Tap: function () { },
  9. DoubleTap: function () { },
  10. LongTap: function () { },
  11. SingleTap: function () { },
  12. Rotate: function (evt) {
  13. console.log(evt.detail.angle)
  14. },
  15. Pinch: function (evt) {
  16. console.log(evt.detail.zoom)
  17. },
  18. PressMove: function (evt) {
  19. console.log(evt.detail.deltaX)
  20. console.log(evt.detail.deltaY)
  21. },
  22. Swipe: function (evt) {
  23. console.log("swipe" + evt.detail.direction)
  24. }
  25. }