mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Fixed nav controller scoping and isVisible
This commit is contained in:
91
dist/js/ionic-angular.js
vendored
91
dist/js/ionic-angular.js
vendored
@ -642,6 +642,31 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
})
|
})
|
||||||
|
|
||||||
.directive('navContent', ['Gesture', '$animate', '$compile', function(Gesture, $animate, $compile) {
|
.directive('navContent', ['Gesture', '$animate', '$compile', function(Gesture, $animate, $compile) {
|
||||||
|
|
||||||
|
var animatePushedController = function(childScope, clone, $element) {
|
||||||
|
var title = angular.element($element.parent().parent().parent()[0].querySelector('.title'));
|
||||||
|
var newTitle = angular.element(title.clone());
|
||||||
|
|
||||||
|
$compile(newTitle)(childScope);
|
||||||
|
title.after(newTitle);
|
||||||
|
|
||||||
|
clone.addClass(childScope.slideAnimation);
|
||||||
|
|
||||||
|
$animate.addClass(newTitle, childScope.slideTitleAnimation, function() {
|
||||||
|
$animate.removeClass(newTitle, childScope.slideTitleAnimation, function() {
|
||||||
|
newTitle.scope().$destroy();
|
||||||
|
newTitle.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var title = $element.parent().parent().parent()[0].querySelector('.title');
|
||||||
|
$animate.enter(clone, $element.parent(), $element);
|
||||||
|
$animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
||||||
|
$animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: 'ECA',
|
restrict: 'ECA',
|
||||||
require: '^navs',
|
require: '^navs',
|
||||||
@ -650,6 +675,20 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
return function($scope, $element, $attr, navCtrl) {
|
return function($scope, $element, $attr, navCtrl) {
|
||||||
var lastParent, lastIndex, childScope, childElement;
|
var lastParent, lastIndex, childScope, childElement;
|
||||||
|
|
||||||
|
|
||||||
|
$scope.title = $attr.title;
|
||||||
|
$scope.slideAnimation = $attr.slideAnimation || '';
|
||||||
|
$scope.slideTitleAnimation = $attr.slideTitleAnimation || '';
|
||||||
|
|
||||||
|
if($attr.navBar === "false") {
|
||||||
|
navCtrl.hideNavBar();
|
||||||
|
} else {
|
||||||
|
navCtrl.showNavBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push this controller onto the stack
|
||||||
|
$scope.pushController($scope, $element);
|
||||||
|
|
||||||
$scope.$watch('isVisible', function(value) {
|
$scope.$watch('isVisible', function(value) {
|
||||||
// Taken from ngIf
|
// Taken from ngIf
|
||||||
if(childElement) {
|
if(childElement) {
|
||||||
@ -661,58 +700,14 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
childScope = undefined;
|
childScope = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if this is visible, and if so, create it and show it
|
||||||
if(value) {
|
if(value) {
|
||||||
childScope = $scope;
|
childScope = $scope.$new();
|
||||||
|
|
||||||
transclude(childScope, function(clone) {
|
transclude(childScope, function(clone) {
|
||||||
childElement = clone;
|
childElement = clone;
|
||||||
|
|
||||||
childScope.title = $attr.title;
|
animatePushedController(childScope, clone, $element);
|
||||||
childScope.slideAnimation = $attr.slideAnimation || '';
|
|
||||||
childScope.slideTitleAnimation = $attr.slideTitleAnimation || '';
|
|
||||||
|
|
||||||
if($attr.navBar === "false") {
|
|
||||||
navCtrl.hideNavBar();
|
|
||||||
} else {
|
|
||||||
navCtrl.showNavBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
childScope.pushController(childScope, $element);
|
|
||||||
|
|
||||||
var title = angular.element($element.parent().parent().parent()[0].querySelector('.title'));
|
|
||||||
var newTitle = angular.element(title.clone());
|
|
||||||
|
|
||||||
$compile(newTitle)(childScope);
|
|
||||||
|
|
||||||
title.after(newTitle);
|
|
||||||
|
|
||||||
console.log(newTitle);
|
|
||||||
|
|
||||||
clone.addClass(childScope.slideAnimation);
|
|
||||||
|
|
||||||
$animate.addClass(newTitle, childScope.slideTitleAnimation, function() {
|
|
||||||
$animate.removeClass(newTitle, childScope.slideTitleAnimation, function() {
|
|
||||||
newTitle.scope().$destroy();
|
|
||||||
newTitle.remove();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
Gesture.on('drag', function(e) {
|
|
||||||
//navCtrl.handleDrag(e);
|
|
||||||
console.log('Content drag', e);
|
|
||||||
}, childElement[0]);
|
|
||||||
|
|
||||||
Gesture.on('release', function(e) {
|
|
||||||
//navCtrl._endDrag(e);
|
|
||||||
}, childElement[0]);
|
|
||||||
*/
|
|
||||||
|
|
||||||
var title = $element.parent().parent().parent()[0].querySelector('.title');
|
|
||||||
$animate.enter(clone, $element.parent(), $element);
|
|
||||||
$animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
|
||||||
$animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
91
js/ext/angular/src/directive/ionicNav.js
vendored
91
js/ext/angular/src/directive/ionicNav.js
vendored
@ -97,6 +97,31 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
})
|
})
|
||||||
|
|
||||||
.directive('navContent', ['Gesture', '$animate', '$compile', function(Gesture, $animate, $compile) {
|
.directive('navContent', ['Gesture', '$animate', '$compile', function(Gesture, $animate, $compile) {
|
||||||
|
|
||||||
|
var animatePushedController = function(childScope, clone, $element) {
|
||||||
|
var title = angular.element($element.parent().parent().parent()[0].querySelector('.title'));
|
||||||
|
var newTitle = angular.element(title.clone());
|
||||||
|
|
||||||
|
$compile(newTitle)(childScope);
|
||||||
|
title.after(newTitle);
|
||||||
|
|
||||||
|
clone.addClass(childScope.slideAnimation);
|
||||||
|
|
||||||
|
$animate.addClass(newTitle, childScope.slideTitleAnimation, function() {
|
||||||
|
$animate.removeClass(newTitle, childScope.slideTitleAnimation, function() {
|
||||||
|
newTitle.scope().$destroy();
|
||||||
|
newTitle.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var title = $element.parent().parent().parent()[0].querySelector('.title');
|
||||||
|
$animate.enter(clone, $element.parent(), $element);
|
||||||
|
$animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
||||||
|
$animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: 'ECA',
|
restrict: 'ECA',
|
||||||
require: '^navs',
|
require: '^navs',
|
||||||
@ -105,6 +130,20 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
return function($scope, $element, $attr, navCtrl) {
|
return function($scope, $element, $attr, navCtrl) {
|
||||||
var lastParent, lastIndex, childScope, childElement;
|
var lastParent, lastIndex, childScope, childElement;
|
||||||
|
|
||||||
|
|
||||||
|
$scope.title = $attr.title;
|
||||||
|
$scope.slideAnimation = $attr.slideAnimation || '';
|
||||||
|
$scope.slideTitleAnimation = $attr.slideTitleAnimation || '';
|
||||||
|
|
||||||
|
if($attr.navBar === "false") {
|
||||||
|
navCtrl.hideNavBar();
|
||||||
|
} else {
|
||||||
|
navCtrl.showNavBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push this controller onto the stack
|
||||||
|
$scope.pushController($scope, $element);
|
||||||
|
|
||||||
$scope.$watch('isVisible', function(value) {
|
$scope.$watch('isVisible', function(value) {
|
||||||
// Taken from ngIf
|
// Taken from ngIf
|
||||||
if(childElement) {
|
if(childElement) {
|
||||||
@ -116,58 +155,14 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges
|
|||||||
childScope = undefined;
|
childScope = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if this is visible, and if so, create it and show it
|
||||||
if(value) {
|
if(value) {
|
||||||
childScope = $scope;
|
childScope = $scope.$new();
|
||||||
|
|
||||||
transclude(childScope, function(clone) {
|
transclude(childScope, function(clone) {
|
||||||
childElement = clone;
|
childElement = clone;
|
||||||
|
|
||||||
childScope.title = $attr.title;
|
animatePushedController(childScope, clone, $element);
|
||||||
childScope.slideAnimation = $attr.slideAnimation || '';
|
|
||||||
childScope.slideTitleAnimation = $attr.slideTitleAnimation || '';
|
|
||||||
|
|
||||||
if($attr.navBar === "false") {
|
|
||||||
navCtrl.hideNavBar();
|
|
||||||
} else {
|
|
||||||
navCtrl.showNavBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
childScope.pushController(childScope, $element);
|
|
||||||
|
|
||||||
var title = angular.element($element.parent().parent().parent()[0].querySelector('.title'));
|
|
||||||
var newTitle = angular.element(title.clone());
|
|
||||||
|
|
||||||
$compile(newTitle)(childScope);
|
|
||||||
|
|
||||||
title.after(newTitle);
|
|
||||||
|
|
||||||
console.log(newTitle);
|
|
||||||
|
|
||||||
clone.addClass(childScope.slideAnimation);
|
|
||||||
|
|
||||||
$animate.addClass(newTitle, childScope.slideTitleAnimation, function() {
|
|
||||||
$animate.removeClass(newTitle, childScope.slideTitleAnimation, function() {
|
|
||||||
newTitle.scope().$destroy();
|
|
||||||
newTitle.remove();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
Gesture.on('drag', function(e) {
|
|
||||||
//navCtrl.handleDrag(e);
|
|
||||||
console.log('Content drag', e);
|
|
||||||
}, childElement[0]);
|
|
||||||
|
|
||||||
Gesture.on('release', function(e) {
|
|
||||||
//navCtrl._endDrag(e);
|
|
||||||
}, childElement[0]);
|
|
||||||
*/
|
|
||||||
|
|
||||||
var title = $element.parent().parent().parent()[0].querySelector('.title');
|
|
||||||
$animate.enter(clone, $element.parent(), $element);
|
|
||||||
$animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
|
||||||
$animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() {
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user