assets/javascripts/material/components/tab-switch.js in material-sass-4.0.0 vs assets/javascripts/material/components/tab-switch.js in material-sass-4.1.0
- old
+ new
@@ -1,18 +1,14 @@
/*
* Tab indicator animation
- * Requires Bootstrap's (v4.0.0) `tab.js`
+ * Requires Bootstrap's (v4.1.0) `tab.js`
*/
var TabSwitch = function ($) {
// constants >>>
var DATA_KEY = 'md.tabswitch';
var NAME = 'tabswitch';
var NO_CONFLICT = $.fn[NAME];
- var Breakpoints = {
- DESKTOP: 992,
- TABLET: 576
- };
var ClassName = {
ANIMATE: 'animate',
DROPDOWN_ITEM: 'dropdown-item',
INDICATOR: 'nav-tabs-indicator',
MATERIAL: 'nav-tabs-material',
@@ -23,16 +19,11 @@
SHOW_BS_TAB: 'show.bs.tab'
};
var Selector = {
DATA_TOGGLE: '.nav-tabs [data-toggle="tab"]',
DROPDOWN: '.dropdown',
- NAV: '.nav-tabs'
- };
- var TransitionDuration = {
- DESKTOP: 200,
- MOBILE: 300,
- TABLET: 390 // <<< constants
+ NAV: '.nav-tabs' // <<< constants
};
var TabSwitch =
/*#__PURE__*/
@@ -82,25 +73,18 @@
if (!supportsTransition) {
complete();
return;
}
- var transitionDuration = TransitionDuration.MOBILE;
-
- if (window.innerWidth >= Breakpoints.DESKTOP) {
- transitionDuration = TransitionDuration.DESKTOP;
- } else if (window.innerWidth >= Breakpoints.TABLET) {
- transitionDuration = TransitionDuration.TABLET;
- }
-
+ var transitionDuration = Util.getTransitionDurationFromElement(this._navindicator);
$(this._navindicator).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
};
_proto._createIndicator = function _createIndicator(navLeft, navScrollLeft, navWidth, relatedTarget) {
this._navindicator = document.createElement('div');
$(this._navindicator).addClass(ClassName.INDICATOR).appendTo(this._nav);
- if (relatedTarget !== 'undefined') {
+ if (typeof relatedTarget !== 'undefined') {
if ($(relatedTarget).hasClass(ClassName.DROPDOWN_ITEM)) {
relatedTarget = $(relatedTarget).closest(Selector.DROPDOWN);
}
var relatedLeft = $(relatedTarget).offset().left;