refactor(clickBlock): add click-block div to body

Instead of using pointer-events: none to disable unwanted clicks which
can cause flickering, we’re now using a click-block div that covers the
view during transitions. Similar concept to pointer-events: none
applied to the body tag, but in tests its showing to be more effective
to not cause any flickers.
This commit is contained in:
Adam Bradley
2014-08-27 12:56:12 -05:00
parent 2c3f1c9f02
commit e9f0fcf556
5 changed files with 63 additions and 25 deletions

24
js/angular/service/clickBlock.js vendored Normal file
View File

@@ -0,0 +1,24 @@
IonicModule
.factory('$ionicClickBlock', [
'$document',
'$ionicBody',
'$timeout',
function($document, $ionicBody, $timeout) {
var cb = $document[0].createElement('div');
cb.className = 'click-block';
return {
show: function() {
if(cb.parentElement) {
cb.classList.remove('hide');
} else {
$ionicBody.append(cb);
}
$timeout(function(){
cb.classList.add('hide');
}, 500);
},
hide: function() {
cb.classList.add('hide');
}
};
}]);

View File

@@ -94,7 +94,8 @@ function($rootScope, $state, $location, $document, $animate, $ionicPlatform, $io
'$injector',
'$animate',
'$ionicNavViewConfig',
function($rootScope, $state, $location, $window, $injector, $animate, $ionicNavViewConfig) {
'$ionicClickBlock',
function($rootScope, $state, $location, $window, $injector, $animate, $ionicNavViewConfig, $ionicClickBlock) {
var View = function(){};
View.prototype.initialize = function(data) {
@@ -477,17 +478,17 @@ function($rootScope, $state, $location, $window, $injector, $animate, $ionicNavV
setAnimationClass();
element.addClass('ng-enter');
document.body.classList.add('disable-pointer-events');
$ionicClickBlock.show();
$animate.enter(element, navViewElement, null, function() {
document.body.classList.remove('disable-pointer-events');
$ionicClickBlock.hide();
if (animationClass) {
navViewElement[0].classList.remove(animationClass);
}
});
return;
} else if(!doAnimation) {
document.body.classList.remove('disable-pointer-events');
$ionicClickBlock.hide();
}
// no animation