[+] Create function to determine block width
This commit is contained in:
@@ -11,6 +11,22 @@ export default class Responsive
|
|||||||
this.minWidth = minWidth;
|
this.minWidth = minWidth;
|
||||||
this.margin = margin;
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user