From 45c03c2b40c39e6f118c111d66b3b279564acd57 Mon Sep 17 00:00:00 2001 From: NihadBadalov <32594553+NihadBadalov@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:31:31 +0100 Subject: [PATCH] Feat: Add optional width parameter to isMobile() method --- src/mixins/mobile.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mixins/mobile.js b/src/mixins/mobile.js index c44edcff3..1f84c1bfc 100644 --- a/src/mixins/mobile.js +++ b/src/mixins/mobile.js @@ -36,8 +36,14 @@ export default { }, computed: { - isMobile() { - return this.windowWidth <= 767.98; + /** + * @param {number? | undefined} width Width of the device + * @returns {boolean} Whether the device is mobile + */ + isMobile(width) { + return (width && typeof width === "number" + ? width ?? this.windowWidth + : this.windowWidth) <= 767.98; }, },