Skip to content

Commit

Permalink
fix(clickBlock): cancel pending show if already hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Dec 3, 2014
1 parent 6b4963e commit 0967849
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions js/angular/service/clickBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,32 @@ IonicModule
function($document, $ionicBody, $timeout) {
var fallbackTimer, isAttached;
var CSS_HIDE = 'click-block-hide';
var pendingShow;

var cb = $document[0].createElement('div');
cb.className = 'click-block';

return {
show: function(autoExpire) {
pendingShow = true;
// cancel the fallback timer
$timeout.cancel(fallbackTimer);

ionic.requestAnimationFrame(function() {
if (isAttached) {
cb.classList.remove(CSS_HIDE);
} else {
$ionicBody.append(cb);
isAttached = true;
if (pendingShow) {
if (isAttached) {
cb.classList.remove(CSS_HIDE);
} else {
$ionicBody.append(cb);
isAttached = true;
}
}
});

fallbackTimer = $timeout(function() {
cb.classList.add(CSS_HIDE);
}, autoExpire || 300);
fallbackTimer = $timeout(this.hide, autoExpire || 310);
},
hide: function() {
pendingShow = false;
$timeout.cancel(fallbackTimer);
cb.classList.add(CSS_HIDE);
}
Expand Down

0 comments on commit 0967849

Please sign in to comment.