long-press-mobile

移动端长按事件

Usage no npm install needed!

<script type="module">
  import longPressMobile from 'https://cdn.skypack.dev/long-press-mobile';
</script>

README

usage

install

npm install long-press-mobile
yarn add long-press-mobile

html

    <button class="plus">plus</button>
    <button class="minus">minus</button>

javascript

import { LongPress } from 'long-press'

let count = 0
new LongPress('.plus', () => {
    count++
    console.log('count:', count)
})

new LongPress('.minus', () => {
    count--
    console.log('count:', count)
})

@params

/**
 * desc 长按页面事件
 * @param {String} selector 字符串选择器
 * @param {Function} cb 长按事件持续执行回调
 */
new LongPress(selector, cb)