refactor(clickBlock): ensure click block fallback cancels

This commit is contained in:
Adam Bradley
2014-09-26 08:15:21 -05:00
parent 4c83bedf32
commit f0af085841

View File

@@ -4,21 +4,33 @@ IonicModule
'$ionicBody',
'$timeout',
function($document, $ionicBody, $timeout) {
var fallbackTimer;
var cb = $document[0].createElement('div');
cb.className = 'click-block';
return {
show: function() {
// cancel the fallback timer
$timeout.cancel( fallbackTimer );
if(cb.parentElement) {
cb.classList.remove('hide');
} else {
$ionicBody.append(cb);
}
$timeout(function(){
fallbackTimer = $timeout(function(){
cb.classList.add('hide');
}, 500);
},
hide: function() {
cb.classList.add('hide');
// cancel the fallback timer
$timeout.cancel( fallbackTimer );
// should be a minimum time it should hide
ionic.requestAnimationFrame(function(){
cb.classList.add('hide');
});
}
};
}]);