rsuite
Version:
A suite of react components
33 lines (31 loc) • 855 B
JavaScript
'use client';
;
exports.__esModule = true;
exports.checkValue = checkValue;
exports.getPosition = getPosition;
exports.precisionMath = void 0;
const precisionMath = value => parseFloat(value.toFixed(10));
exports.precisionMath = precisionMath;
function checkValue(value, min, max) {
if (typeof value === 'undefined' || value === null) {
return value;
}
if (typeof value === 'number' && value < min) {
return min;
}
if (typeof value === 'number' && value > max) {
return max;
}
return value;
}
function getPosition(e) {
let event = 'touches' in e ? e.touches[0] : e;
// For touchend event, we need to use `changedTouches` instead of `touches`
if (e.type === 'touchend' && 'changedTouches' in e) {
event = e.changedTouches[0];
}
return {
pageX: event?.pageX || 0,
pageY: event?.pageY || 0
};
}