From 180e2c4b38c05f456d190c14be86c69faf46c02d Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sun, 12 Aug 2018 00:05:38 +0200 Subject: [PATCH] feat: add "MediaQuery.only()" Add method: * `MediaQuery.only(size)` Checks if the screen is within the given breakpoint. If smaller than the breakpoint of wider than its upper limit, returns false. --- js/foundation.util.mediaQuery.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/foundation.util.mediaQuery.js b/js/foundation.util.mediaQuery.js index 9a9931c1f..ef31362c6 100644 --- a/js/foundation.util.mediaQuery.js +++ b/js/foundation.util.mediaQuery.js @@ -142,6 +142,17 @@ var MediaQuery = { return false; }, + /** + * Checks if the screen is within the given breakpoint. + * If smaller than the breakpoint of wider than its upper limit, returns false. + * @function + * @param {String} size - Name of the breakpoint to check. + * @returns {Boolean} `true` if the breakpoint matches, `false` otherwise. + */ + only(size) { + return size === this._getCurrentSize(); + }, + /** * Checks if the screen is within a breakpoint or smaller. * @function @@ -174,7 +185,7 @@ var MediaQuery = { // Only the breakpont if (bpModifier === 'only') { - return bpSize === this._getCurrentSize(); + return this.only(bpSize); } // Up to the breakpoint (included) if (bpModifier === 'down') { -- 2.47.2