Skip to content

Commit

Permalink
Not animated tabs
Browse files Browse the repository at this point in the history
Ref #1298
  • Loading branch information
nolimits4web committed Jan 28, 2017
1 parent f251c98 commit e3136c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/js/framework7/tabs.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/* ===============================================================================
************ Tabs ************
=============================================================================== */
app.showTab = function (tab, tabLink, force) {
app.showTab = function (tab, tabLink, animated, force) {
var newTab = $(tab);
if (arguments.length === 2) {
if (typeof tabLink === 'boolean') {
force = tabLink;
}
if (arguments.length === 2 && typeof arguments[1] === 'boolean') {
tab = arguments[0];
animated = arguments[1];
}
if (arguments.length === 3 && typeof arguments[1] === 'boolean' && typeof arguments[2] === 'boolean') {
tab = arguments[0];
animated = arguments[1];
force = arguments[2];
}
if (typeof animated === 'undefined') animated = true;
if (newTab.length === 0) return false;
if (newTab.hasClass('active')) {
if (force) newTab.trigger('show tab:show');
Expand All @@ -22,6 +27,7 @@ app.showTab = function (tab, tabLink, force) {
// Animated tabs
var isAnimatedTabs = tabs.parent().hasClass('tabs-animated-wrap');
if (isAnimatedTabs) {
tabs.parent()[animated ? 'removeClass' : 'addClass']('not-animated');
var tabTranslate = (app.rtl ? newTab.index() : -newTab.index()) * 100;
tabs.transform('translate3d(' + tabTranslate + '%,0,0)');
}
Expand All @@ -30,7 +36,7 @@ app.showTab = function (tab, tabLink, force) {
var isSwipeableTabs = tabs.parent().hasClass('tabs-swipeable-wrap'), swiper;
if (isSwipeableTabs) {
swiper = tabs.parent()[0].swiper;
if (swiper.activeIndex !== newTab.index()) swiper.slideTo(newTab.index(), undefined, false);
if (swiper.activeIndex !== newTab.index()) swiper.slideTo(newTab.index(), animated ? undefined : 0, false);
}

// Remove active class from old tabs
Expand Down
3 changes: 3 additions & 0 deletions src/less/ios/tabs.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
.flex-shrink(0);
}
}
&.not-animated > .tabs {
.transition(0ms);
}
}
.tabs-swipeable-wrap {
height: 100%;
Expand Down
3 changes: 3 additions & 0 deletions src/less/material/tabs.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
.flex-shrink(0);
}
}
&.not-animated > .tabs {
.transition(0ms);
}
}
.tabs-swipeable-wrap {
height: 100%;
Expand Down

0 comments on commit e3136c5

Please sign in to comment.