UNPKG

hy-checkbox

Version:

checkbox & radio ui components for react

33 lines (28 loc) 917 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isEventFromHandle = isEventFromHandle; exports.getMousePosition = getMousePosition; exports.getTouchPosition = getTouchPosition; exports.getHandleCenterPosition = getHandleCenterPosition; exports.pauseEvent = pauseEvent; function isEventFromHandle(e, handles) { return Object.keys(handles).some(function (key) { return e.target === findDOMNode(handles[key]); }); } function getMousePosition(vertical, e) { return vertical ? e.clientY : e.pageX; } function getTouchPosition(vertical, e) { return vertical ? e.touches[0].clientY : e.touches[0].pageX; } function getHandleCenterPosition(vertical, handle) { var coords = handle.getBoundingClientRect(); return vertical ? coords.top + coords.height * 0.5 : coords.left + coords.width * 0.5; } function pauseEvent(e) { e.stopPropagation(); e.preventDefault(); }