further simplification

This commit is contained in:
zadam 2019-05-12 10:21:27 +02:00
parent b9edd0ecc7
commit c39c1baa4d

View File

@ -9,8 +9,6 @@
const Draggabilly = window.Draggabilly; const Draggabilly = window.Draggabilly;
const TAB_CONTENT_OVERLAP_DISTANCE = 1;
const TAB_CONTENT_MIN_WIDTH = 24; const TAB_CONTENT_MIN_WIDTH = 24;
const TAB_CONTENT_MAX_WIDTH = 240; const TAB_CONTENT_MAX_WIDTH = 240;
@ -107,11 +105,10 @@ class TabRow {
get tabContentWidths() { get tabContentWidths() {
const numberOfTabs = this.tabEls.length; const numberOfTabs = this.tabEls.length;
const tabsContentWidth = this.tabContentEl.clientWidth; const tabsContentWidth = this.tabContentEl.clientWidth;
const tabsCumulativeOverlappedWidth = (numberOfTabs - 1) * TAB_CONTENT_OVERLAP_DISTANCE; const targetWidth = tabsContentWidth / numberOfTabs;
const targetWidth = (tabsContentWidth + tabsCumulativeOverlappedWidth) / numberOfTabs;
const clampedTargetWidth = Math.max(TAB_CONTENT_MIN_WIDTH, Math.min(TAB_CONTENT_MAX_WIDTH, targetWidth)); const clampedTargetWidth = Math.max(TAB_CONTENT_MIN_WIDTH, Math.min(TAB_CONTENT_MAX_WIDTH, targetWidth));
const flooredClampedTargetWidth = Math.floor(clampedTargetWidth); const flooredClampedTargetWidth = Math.floor(clampedTargetWidth);
const totalTabsWidthUsingTarget = (flooredClampedTargetWidth * numberOfTabs) - tabsCumulativeOverlappedWidth; const totalTabsWidthUsingTarget = flooredClampedTargetWidth * numberOfTabs;
const totalExtraWidthDueToFlooring = tabsContentWidth - totalTabsWidthUsingTarget; const totalExtraWidthDueToFlooring = tabsContentWidth - totalTabsWidthUsingTarget;
const widths = []; const widths = [];
@ -130,9 +127,8 @@ class TabRow {
const tabContentWidths = this.tabContentWidths; const tabContentWidths = this.tabContentWidths;
let position = 0; let position = 0;
tabContentWidths.forEach((width, i) => { tabContentWidths.forEach(width => {
const offset = i * TAB_CONTENT_OVERLAP_DISTANCE; positions.push(position);
positions.push(position - offset);
position += width; position += width;
}); });