UNPKG

apex4x

Version:

The Comprehensive ARIA Development Suite

27 lines 2.82 kB
�� Function: getOrientation(arrayOfElements) Description: The getOrientation() function will compute the visual layout of an array of DOM elements to determine if they are rendered horizontally or vertically. Returns: Object. Note: The returned object includes 2 properties, "orientation" and "lineWrap". The lineWrap property is a boolean value confirming if the specified elements are positioned horizontally but also wrap onto different lines. Depending on the result of the calculation, the orientation property will include a string value stating either "horizontal" or "vertical". This functionality is meant to control keyboard handling adjustments for interactive widgets that require arrow key usage for internal navigation. Example: // Get the orientation for an array of DOM elements rendered adjacent to each other. var myOrientation = $A.getOrientation(arrayOfElements); // Get the orientation for an array of DOM elements using a CSS selector. var myOrientation = $A.getOrientation('#myMenu[role="menu"] > *[role="menuitem"]'); Result myOrientation.orientation // Will be either "horizontal" or "vertical". myOrientation.lineWrap // Will be either true or false. // The returned value of the orientation property is designed to be directly applicable to the aria-orientation attribute. $A(myMenu).setAttribute("aria-orientation", myOrientation.orientation);