From c3d858a24e1a931d073a17b3185c2cd79b2628de Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 30 Sep 2014 11:26:19 -0600 Subject: [PATCH] fix(ripple): make detach method work properly --- src/components/animate/inkCssRipple.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/animate/inkCssRipple.js b/src/components/animate/inkCssRipple.js index 062f9a444a5..39db3cdba58 100644 --- a/src/components/animate/inkCssRipple.js +++ b/src/components/animate/inkCssRipple.js @@ -84,21 +84,15 @@ function InkRippleService($window, $$rAF, $materialEffects, $timeout) { // Publish self-detach method if desired... return function detach() { listenPointerDown(false); - - if ( rippleContainer ) { - // Self-removal of injected container... - rippleContainer - .parent() - .remove( rippleContainer ); + if (rippleContainer) { + rippleContainer.remove(); } }; - function listenPointerDown(active) { - if ( !active) element.off(POINTERDOWN_EVENT, onPointerDown); - else element.on(POINTERDOWN_EVENT, onPointerDown); + function listenPointerDown(shouldListen) { + element[shouldListen ? 'on' : 'off'](POINTERDOWN_EVENT, onPointerDown); } - function rippleIsAllowed() { return !Util.isParentDisabled(element); } @@ -155,14 +149,14 @@ function InkRippleService($window, $$rAF, $materialEffects, $timeout) { rippleEl.on('$destroy', cancelRipplePause); // Stop listening to pointer down for now, until the user lifts their finger/mouse - element.off(POINTERDOWN_EVENT, onPointerDown); + listenPointerDown(false); element.on(POINTERUP_EVENT, onPointerUp); function onPointerUp() { cancelRipplePause(); rippleEl.css($materialEffects.ANIMATION_PLAY_STATE, 'running'); element.off(POINTERUP_EVENT, onPointerUp); - element.on(POINTERDOWN_EVENT, onPointerDown); + listenPointerDown(true); } function pauseRipple() { rippleEl.css($materialEffects.ANIMATION_PLAY_STATE, 'paused');