Skip to content

Commit

Permalink
fix(ripple): make detach method work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Sep 30, 2014
1 parent 3b38627 commit c3d858a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/components/animate/inkCssRipple.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit c3d858a

Please sign in to comment.