Skip to content

Commit

Permalink
Update ElementQueries.js
Browse files Browse the repository at this point in the history
Add support for "orientation" queries ['landscape' |'portrait'|'square']
see marcj#288
  • Loading branch information
steveoriol authored May 3, 2021
1 parent 4eae465 commit cb3cc8b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ElementQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand All @@ -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 = {};

Expand Down Expand Up @@ -159,6 +161,7 @@
this.element.removeAttribute(attributes[k]);
}
}
this.element.setAttribute("orientation", orientation);
};
}

Expand Down

0 comments on commit cb3cc8b

Please sign in to comment.