Comparing version 0.0.13 to 0.0.14
/*! | ||
* Eyzy v0.0.12 | ||
* Eyzy v0.0.13 | ||
* (c) 2022 amsik | ||
@@ -212,20 +212,25 @@ * Released under the MIT License. | ||
_this.tryHeaderScroll = function () { | ||
var _a, _b, _c, _d; | ||
try { | ||
var activeTab = (_a = _this.wrap.current) === null || _a === void 0 ? void 0 : _a.querySelector('.active'); | ||
if (!activeTab) { | ||
var wrap = _this.wrap.current; | ||
var activeTab = wrap === null || wrap === void 0 ? void 0 : wrap.querySelector('.active'); | ||
if (!activeTab || !wrap) { | ||
return; | ||
} | ||
var wrapBounds = (_b = _this.wrap.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect(); | ||
var wrapBounds = wrap.getBoundingClientRect(); | ||
var wrapScrollLeft = wrap.scrollLeft; | ||
var activeBounds = activeTab.getBoundingClientRect(); | ||
var nextScroll = null; | ||
if ((wrapBounds === null || wrapBounds === void 0 ? void 0 : wrapBounds.left) > activeBounds.left) { | ||
(_c = _this.wrap.current) === null || _c === void 0 ? void 0 : _c.scrollLeft -= (wrapBounds === null || wrapBounds === void 0 ? void 0 : wrapBounds.left) - activeBounds.left; | ||
nextScroll = wrapScrollLeft - ((wrapBounds === null || wrapBounds === void 0 ? void 0 : wrapBounds.left) - activeBounds.left); | ||
} | ||
else if ((wrapBounds === null || wrapBounds === void 0 ? void 0 : wrapBounds.right) < activeBounds.right) { | ||
(_d = _this.wrap.current) === null || _d === void 0 ? void 0 : _d.scrollLeft += activeBounds.right - (wrapBounds === null || wrapBounds === void 0 ? void 0 : wrapBounds.right); | ||
nextScroll = wrapScrollLeft + (activeBounds.right - wrapBounds.right); | ||
} | ||
if (nextScroll !== null) { | ||
wrap.scrollTo({ left: nextScroll, behavior: 'smooth' }); | ||
} | ||
} | ||
catch (e) { } | ||
}; | ||
_this.setCtrlStates = function () { | ||
_this.setCtrlStates = function (needScroll) { | ||
var container = _this.wrap.current; | ||
@@ -239,3 +244,3 @@ var wrapper = _this.scrollWrap.current; | ||
isArrowVisible: false | ||
}); | ||
}, function () { return needScroll === true && _this.tryHeaderScroll(); }); | ||
} | ||
@@ -250,3 +255,3 @@ var isArrowLeftDisabled = container.scrollLeft === 0; | ||
isArrowVisible: true | ||
}); | ||
}, function () { return needScroll === true && _this.tryHeaderScroll(); }); | ||
}; | ||
@@ -293,3 +298,3 @@ _this.getChildNodes = function (children) { | ||
} | ||
_this.setState({ activeKey: key }); | ||
_this.setState({ activeKey: key }, _this.tryHeaderScroll); | ||
}; | ||
@@ -317,4 +322,3 @@ _this.handleWindowResize = debounce(_this.setCtrlStates, 200); | ||
Tabs.prototype.componentDidMount = function () { | ||
this.tryHeaderScroll(); | ||
this.setCtrlStates(); | ||
this.setCtrlStates(true); | ||
window.addEventListener('resize', this.handleWindowResize); | ||
@@ -321,0 +325,0 @@ }; |
{ | ||
"name": "eyzy", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"author": "Kostiantyn", | ||
@@ -5,0 +5,0 @@ "description": "React UI Toolkit", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
123015
1320