From 6253b481c8854878323140ea0568977347bae664 Mon Sep 17 00:00:00 2001 From: joeliutp Date: Fri, 6 Mar 2020 16:46:21 +0800 Subject: [PATCH 1/2] fix unbind to destroy --- index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 53dc189..ae0e5b5 100644 --- a/index.js +++ b/index.js @@ -130,10 +130,20 @@ export const VueHammer = { if (mc.handler) { el.hammer.off(eventWithDir, mc.handler) } - if (!Object.keys(mc.handlers).length) { + let eventkeys = Object.keys(el.hammer.handlers) + let isDestroy = true + eventkeys.forEach(element => { + if (mc.handlers[element].length > 0) + { + isDestroy = false + } + }) + if (isDestroy) + { + console.warn('[vue-hammer] unbind destroy') el.hammer.destroy() el.hammer = null - } + } }, }) }, From f8d72d6e7ba39be1d59787045ffb68a44107e161 Mon Sep 17 00:00:00 2001 From: joeliutp Date: Fri, 10 Apr 2020 12:11:08 +0800 Subject: [PATCH 2/2] fix ios 13 hammer scrolling on panmove --- README.md | 3 +++ index.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 310393f..88284c8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # vue-hammer +fix ios 13 hammer scrolling on panmove +fix unbind destory + Hammer.js wrapper for Vue to support some operation in the mobile This is a directive wrapper for Hammer.js 2.x. And this repo'inspiration is from v-touch. diff --git a/index.js b/index.js index ae0e5b5..c24d8d6 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,8 @@ export const VueHammer = { Vue.directive('hammer', { bind: (el, binding) => { if (!el.hammer) { - el.hammer = new Hammer.Manager(el) + el.hammer = new Hammer.Manager(el, { inputClass: Hammer.TouchMouseInput }) + el.hammer.domEvents = true } const mc = el.hammer