2.2.4 • Published 7 months ago

touch-and-hold-button v2.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Transform an HTML button to a touch-and-hold (long press) button

  • Prevent accidental button presses with hold confirmation
  • Works with or without Bootstrap

Demo page

Usage

<button type="submit" id="holdButton">Hold Me</button>
<script type="module">
    import {TouchAndHoldButton} from './src/TouchAndHoldButton.js'

    const buttonElement = document.getElementById('holdButton')
    const touchAndHoldButton = new TouchAndHoldButton(buttonElement)

    buttonElement.addEventListener('hold', () => {
        console.log('`hold` event fired.')
    })
    buttonElement.addEventListener('confirm', () => {
        console.log('`confirm` event fired.')
    })
    buttonElement.addEventListener('cancel', () => {
        console.log('`cancel` event fired.')
    })
    buttonElement.addEventListener('action', () => {
        console.log('`action` event fired.')
        alert('Button confirmed action')
    })
</script>

Default props

this.props = {
    holdDuration: 1000,
    fillColor: "rgba(0,0,0,0.1)",
    confirmedShadow: "0 0 0 5px rgba(0,100,0,0.5)"
}
2.2.4

7 months ago

2.2.3

7 months ago

2.2.2

7 months ago

2.2.1

7 months ago

2.1.0

7 months ago

2.0.2

7 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago