mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(clickBlock): ensure click block fallback cancels
This commit is contained in:
16
js/angular/service/clickBlock.js
vendored
16
js/angular/service/clickBlock.js
vendored
@@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user