From 3e496833fc5b5ec1764134a09b6d18617b1d356d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 26 Nov 2018 16:41:49 +0100 Subject: [PATCH] remove unused PercentageDistributor it's not used and we need to make some api changes that don't work with it (resize will receive itemSize which it doesn't really support) --- src/resizer/distributors.js | 48 ------------------------------------- src/resizer/index.js | 3 +-- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/src/resizer/distributors.js b/src/resizer/distributors.js index 29e97e0bce..3c3fd72621 100644 --- a/src/resizer/distributors.js +++ b/src/resizer/distributors.js @@ -73,55 +73,7 @@ class CollapseDistributor extends FixedDistributor { } } -class PercentageDistributor { - constructor(sizer, item, _config, items, container) { - this.container = container; - this.totalSize = sizer.getTotalSize(); - this.sizer = sizer; - - const itemIndex = items.indexOf(item); - this.beforeItems = items.slice(0, itemIndex); - this.afterItems = items.slice(itemIndex); - const percentages = PercentageDistributor._getPercentages(sizer, items); - this.beforePercentages = percentages.slice(0, itemIndex); - this.afterPercentages = percentages.slice(itemIndex); - } - - resize(offset) { - const percent = offset / this.totalSize; - const beforeSum = - this.beforePercentages.reduce((total, p) => total + p, 0); - const beforePercentages = - this.beforePercentages.map(p => (p / beforeSum) * percent); - const afterSum = - this.afterPercentages.reduce((total, p) => total + p, 0); - const afterPercentages = - this.afterPercentages.map(p => (p / afterSum) * (1 - percent)); - - this.beforeItems.forEach((item, index) => { - this.sizer.setItemPercentage(item, beforePercentages[index]); - }); - this.afterItems.forEach((item, index) => { - this.sizer.setItemPercentage(item, afterPercentages[index]); - }); - } - - static _getPercentages(sizer, items) { - const percentages = items.map(i => sizer.getItemPercentage(i)); - const setPercentages = percentages.filter(p => p !== null); - const unsetCount = percentages.length - setPercentages.length; - const setTotal = setPercentages.reduce((total, p) => total + p, 0); - const implicitPercentage = (1 - setTotal) / unsetCount; - return percentages.map(p => p === null ? implicitPercentage : p); - } - - static setPercentage(el, percent) { - el.style.flexGrow = Math.round(percent * 1000); - } -} - module.exports = { FixedDistributor, CollapseDistributor, - PercentageDistributor, }; diff --git a/src/resizer/index.js b/src/resizer/index.js index 69e1f572e6..0720fa36ce 100644 --- a/src/resizer/index.js +++ b/src/resizer/index.js @@ -15,7 +15,7 @@ limitations under the License. */ import {Sizer, FlexSizer} from "./sizer"; -import {FixedDistributor, CollapseDistributor, PercentageDistributor} from "./distributors"; +import {FixedDistributor, CollapseDistributor} from "./distributors"; import {Resizer} from "./resizer"; import {RoomSizer, RoomDistributor} from "./room"; @@ -25,7 +25,6 @@ module.exports = { FlexSizer, FixedDistributor, CollapseDistributor, - PercentageDistributor, RoomSizer, RoomDistributor, };