dont run route animations when changing tabs

This commit is contained in:
Nick Wientge 2015-01-02 15:50:00 -08:00
parent 5642e3ff92
commit 99214b4036
6 changed files with 34 additions and 6 deletions

View file

@ -28,7 +28,7 @@ Template.ionNavBar.rendered = function () {
insertElement: function(node, next) {
var $node = $(node);
if (!$node.hasClass('title') && !$node.hasClass('button')) {
if (!$node.hasClass('title') && !$node.hasClass('button') || IonNavigation.skipTransitions) {
$node.insertBefore(next);
return;
}
@ -63,7 +63,7 @@ Template.ionNavBar.rendered = function () {
removeElement: function(node) {
var $node = $(node);
if (!$node.hasClass('title') && !$node.hasClass('button')) {
if (!$node.hasClass('title') && !$node.hasClass('button') || IonNavigation.skipTransitions) {
$node.remove();
return;
}

View file

@ -1,3 +1,7 @@
IonNavigation = {
skipTransitions: false
};
Template.ionNavView.created = function () {
Session.setDefault('ionNavDirection', 'forward');
@ -25,7 +29,7 @@ Template.ionNavView.rendered = function () {
this.find('[data-nav-container]')._uihooks = {
insertElement: function(node, next) {
var $node = $(node);
if (!template.transition || !$node.hasClass('view')) {
if (!template.transition || !$node.hasClass('view') || IonNavigation.skipTransitions) {
$node.insertBefore(next);
return;
}
@ -43,7 +47,7 @@ Template.ionNavView.rendered = function () {
removeElement: function(node) {
var $node = $(node);
if (!template.transition || !$node.hasClass('view')) {
if (!template.transition || !$node.hasClass('view') || IonNavigation.skipTransitions) {
$node.remove();
return;
}

View file

@ -1,6 +1,6 @@
<template name="ionTab">
<a class="tab-item tab-item-positive {{isActiveRoute regex=path}}" href="{{url}}">
{{#if isActiveRoute regex=path }}
<a class="tab-item tab-item-positive {{isActive}}" href="{{url}}" data-ion-tab>
{{#if isActive}}
{{> ionIcon icon=activeIcon}}
{{else}}
{{> ionIcon icon=defaultIcon}}

View file

@ -1,3 +1,15 @@
Template.ionTab.events({
'click': function (event, template) {
if (template.data.path) {
Session.set('currentTab', template.data.path);
}
// If the tab's content is being rendered inside of a ionNavView
// we don't want to slide it in when switching tabs
IonNavigation.skipTransitions = true;
}
});
Template.ionTab.helpers({
url: function () {
if (this.href) {
@ -9,6 +21,12 @@ Template.ionTab.helpers({
}
},
isActive: function () {
if (this.path && this.path === Session.get('currentTab')) {
return 'active';
}
},
activeIcon: function () {
if (this.iconOn) {
return this.iconOn;

View file

@ -1,3 +1,8 @@
Template.ionView.rendered = function () {
// Reset our transition preference
IonNavigation.skipTransitions = false;
};
Template.ionView.helpers({
classes: function () {
var classes = ['view'];

View file

@ -101,6 +101,7 @@ Package.onUse(function(api) {
api.export("IonHeaderBar");
api.export("IonLoading");
api.export("IonModal");
api.export("IonNavigation");
api.export("IonPopover");
api.export("IonPopup");
api.export("IonSideMenu");