From cb3cc8b76b90f16dbb3259895c283e0c6874c737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A8ve=20Oriol?= Date: Mon, 3 May 2021 18:49:07 +0200 Subject: [PATCH] Update ElementQueries.js Add support for "orientation" queries ['landscape' |'portrait'|'square'] see https://github.com/marcj/css-element-queries/issues/288 --- src/ElementQueries.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ElementQueries.js b/src/ElementQueries.js index 4fe4298..0aaa57f 100755 --- a/src/ElementQueries.js +++ b/src/ElementQueries.js @@ -111,7 +111,7 @@ */ function SetupInformation(element, id) { this.element = element; - var key, option, elementSize, value, actualValue, attrValues, attrValue, attrName; + var key, option, elementSize, value, actualValue, attrValues, attrValue, attrName, orientation; var attributes = ['min-width', 'min-height', 'max-width', 'max-height']; @@ -121,6 +121,8 @@ this.call = function () { // extract current dimensions elementSize = getElementSize(this.element); + orientation = (elementSize.width > elementSize.height) ? 'landscape' : 'portrait'; + if (elementSize.width == elementSize.height) orientation = 'square'; attrValues = {}; @@ -159,6 +161,7 @@ this.element.removeAttribute(attributes[k]); } } + this.element.setAttribute("orientation", orientation); }; }