From 0051a8a5732eeec13f938b5ec36029af7ded39c4 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 23 Dec 2019 11:10:47 -0500 Subject: [PATCH] [+] Create function to determine block width --- src/responsive.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/responsive.ts b/src/responsive.ts index 94c3363..55b2a5d 100644 --- a/src/responsive.ts +++ b/src/responsive.ts @@ -11,6 +11,22 @@ export default class Responsive this.minWidth = minWidth; this.margin = margin; } + + getBlockWidth(currentWidth: number) + { + // Loop through all the possible numbers on screen + [1, 2, 3, 4, 5, 6].forEach(i => + { + // Calculate margin width + let margins = vhToPx(this.margin) * (i + 1); + + // Calculate block width + let blockWidth = (currentWidth - margins) / i; + + // Return block width + if (blockWidth > this.minWidth && blockWidth < this.maxWidth) return blockWidth; + }); + } } /**