mirror of https://github.com/Lissy93/dashy.git
⚡ Long-press directive ignore right-click
This commit is contained in:
parent
57abd67cf9
commit
689797a170
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const LONG_PRESS_DEFAULT_DELAY = 750;
|
const LONG_PRESS_DEFAULT_DELAY = 750;
|
||||||
const TRIGGER_FOR_RIGHT_CLICK = true;
|
|
||||||
const longPressEvent = new CustomEvent('long-press');
|
const longPressEvent = new CustomEvent('long-press');
|
||||||
|
|
||||||
let startTime = null;
|
let startTime = null;
|
||||||
|
@ -42,10 +41,7 @@ export default {
|
||||||
|
|
||||||
const onPointerDown = (e) => {
|
const onPointerDown = (e) => {
|
||||||
// If event was right-click, then immediately trigger
|
// If event was right-click, then immediately trigger
|
||||||
if (e.button === 2) {
|
if (e.button === 2) return;
|
||||||
if (TRIGGER_FOR_RIGHT_CLICK) triggerEvent();
|
|
||||||
else return;
|
|
||||||
}
|
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
document.addEventListener('pointerup', onPointerUp);
|
document.addEventListener('pointerup', onPointerUp);
|
||||||
el.addEventListener('click', swallowClick);
|
el.addEventListener('click', swallowClick);
|
||||||
|
|
Loading…
Reference in New Issue