mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Better nav click throttling
This commit is contained in:
20
js/ext/angular/src/directive/ionicNav.js
vendored
20
js/ext/angular/src/directive/ionicNav.js
vendored
@ -12,7 +12,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
* Push a template onto the navigation stack.
|
* Push a template onto the navigation stack.
|
||||||
* @param {string} templateUrl the URL of the template to load.
|
* @param {string} templateUrl the URL of the template to load.
|
||||||
*/
|
*/
|
||||||
this.pushFromTemplate = ionic.debounce(function(templateUrl) {
|
this.pushFromTemplate = ionic.throttle(function(templateUrl) {
|
||||||
var childScope = $scope.$new();
|
var childScope = $scope.$new();
|
||||||
childScope.isVisible = true;
|
childScope.isVisible = true;
|
||||||
|
|
||||||
@ -25,12 +25,16 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
$animate.enter(cloned, angular.element(content));
|
$animate.enter(cloned, angular.element(content));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 300, true);
|
}, 300, {
|
||||||
|
trailing: false
|
||||||
|
});
|
||||||
|
|
||||||
// Pop function, debounced
|
// Pop function, throttled
|
||||||
this.popController = ionic.debounce(function() {
|
this.popController = ionic.throttle(function() {
|
||||||
_this.pop();
|
_this.pop();
|
||||||
}, 300, true);
|
}, 300, {
|
||||||
|
trailing: false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
ionic.controllers.NavController.call(this, {
|
ionic.controllers.NavController.call(this, {
|
||||||
@ -191,6 +195,12 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
$scope.visibilityChanged = function(direction) {
|
$scope.visibilityChanged = function(direction) {
|
||||||
lastDirection = direction;
|
lastDirection = direction;
|
||||||
|
|
||||||
|
if($scope.isVisible) {
|
||||||
|
$scope.$broadcast('navContent.shown');
|
||||||
|
} else {
|
||||||
|
$scope.$broadcast('navContent.hidden');
|
||||||
|
}
|
||||||
|
|
||||||
if(!childElement) {
|
if(!childElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,13 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
.controller('CatsCtrl', function($scope, $compile, $element) {
|
.controller('CatsCtrl', function($scope, $compile, $element) {
|
||||||
console.log('Cats', $element);
|
$scope.$on('navContent.shown', function() {
|
||||||
|
console.log('SHOWN');
|
||||||
|
});
|
||||||
|
$scope.$on('navContent.hidden', function() {
|
||||||
|
console.log('HIDDEN');
|
||||||
|
});
|
||||||
|
|
||||||
var items = [];
|
var items = [];
|
||||||
for(var i = 0; i < 100; i++) {
|
for(var i = 0; i < 100; i++) {
|
||||||
items.push({});
|
items.push({});
|
||||||
|
|||||||
Reference in New Issue
Block a user