@mui/x-internal-gestures
Version:
The core engine of GestureEvents, a modern and robust multi-pointer gesture detection library for JavaScript.
26 lines (22 loc) • 828 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isDirectionAllowed = isDirectionAllowed;
/**
* Check if a direction matches one of the allowed directions
*/
function isDirectionAllowed(direction, allowedDirections) {
if (!direction.vertical && !direction.horizontal) {
return false;
}
if (allowedDirections.length === 0) {
return true;
}
// Check if the vertical direction is allowed (if it exists)
const verticalAllowed = direction.vertical === null || allowedDirections.includes(direction.vertical);
// Check if the horizontal direction is allowed (if it exists)
const horizontalAllowed = direction.horizontal === null || allowedDirections.includes(direction.horizontal);
// Both directions must be allowed
return verticalAllowed && horizontalAllowed;
}