diff --git a/src/directives/ripple.js b/src/directives/ripple.js index 3fe9c2a8b41..2aca5cf3216 100644 --- a/src/directives/ripple.js +++ b/src/directives/ripple.js @@ -81,21 +81,24 @@ export default { } } - const ctx = {enabled: value !== false} + const + ctx = {enabled: value !== false}, + h = {} if (Platform.is.desktop) { - ctx.mousedown = show - ctx.mouseup = hide - ctx.mouseleave = hide + h.mousedown = show + h.mouseup = hide + h.mouseleave = hide } if (Platform.has.touch) { - ctx.touchstart = show - ctx.touchend = hide - ctx.touchcancel = hide + h.touchstart = show + h.touchend = hide + h.touchcancel = hide } + ctx.h = h el.__qripple = ctx - Object.keys(ctx).forEach(evt => { + Object.keys(h).forEach(evt => { el.addEventListener(evt, ctx[evt], false) }) }, @@ -110,7 +113,7 @@ export default { } const ctx = el.__qripple - Object.keys(ctx).forEach(evt => { + Object.keys(ctx.h).forEach(evt => { el.removeEventListener(evt, ctx[evt], false) }) delete el.__qripple