diff options
Diffstat (limited to 'src/js/utils.js')
-rw-r--r-- | src/js/utils.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/js/utils.js b/src/js/utils.js index 70519fac..1c3d6ed8 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -631,6 +631,13 @@ const utils = { return fragment.firstChild.innerText; }, + // Get aspect ratio for dimensions + getAspectRatio(width, height) { + const getRatio = (w, h) => (h === 0 ? w : getRatio(h, w % h)); + const ratio = getRatio(width, height); + return `${width / ratio}:${height / ratio}`; + }, + // Get the transition end event transitionEnd: (() => { const element = document.createElement('span'); |