omi/packages/omi-finger
dntzhang b9f0d6ae66 chore: change omijs.org to tencent.github.io/omi/ 2019-10-18 11:17:16 +08:00
..
examples/simple chore: change omijs.org to tencent.github.io/omi/ 2019-10-18 11:17:16 +08:00
README.md update readme 2018-10-28 22:01:41 +08:00
index.js omi-finger - update swipe direction detector 2018-11-21 08:58:24 +08:00
package.json omi-finger - update swipe direction detector 2018-11-21 08:58:24 +08:00
webpack.config.js omi v4.0.10 - cloneElement and fix props.children 2018-10-28 21:09:44 +08:00

README.md

omi-finger

Support touch and gesture events in your Omi project.

→ touch the mobile demo

Usage

import { render, tag, WeElement } from 'omi'
import 'omi-finger'

@tag('my-app')
class MyApp extends WeElement {
  install() {
    this.data.wording = 'Tap or Swipe Me!'
  }

  handleTap = (evt) => {
    this.data.wording += '\r\nTap'
    this.update()
  }

  handleSwipe = (evt) => {
    this.data.wording += '\r\nSwipe-' + evt.direction
    this.update()
  }

  render() {
    return (
      <div>
        <omi-finger onTap={this.handleTap} abc={{a:1}} onSwipe={this.handleSwipe}>
          <div class="touchArea" >
            {this.data.wording}
          </div>
        </omi-finger>
      </div>
    )
  }

  css() {
    return `.touchArea{
                  background-color: green;
                  width: 200px;
                  min-height: 200px;
                  text-align: center;
                  color:white;
                  height:auto;
                  white-space: pre-line;
              }`
  }
}

render(<my-app></my-app>, 'body')

License

MIT © dntzhang