@devshack/react-circular-input
Version:
React components for easily composing a circular range input
34 lines • 1.52 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var _1 = require("./");
exports.CircularThumb = function (props) {
var _a = _1.useCircularInputContext(), getPointFromValue = _a.getPointFromValue, isFocused = _a.isFocused, setFocused = _a.setFocused;
var point = getPointFromValue();
if (!point)
return null;
var x = point.x, y = point.y;
var ref = react_1.useRef(null);
var isDragging = _1.useCircularDrag(ref).isDragging;
var style = __assign({ transition: 'r 150ms cubic-bezier(0.215, 0.61, 0.355, 1)' }, (props.style || {}));
return (react_1.default.createElement("circle", __assign({ r: isFocused || isDragging ? 23 : 20, fill: "#0045e5" }, props, { style: style, ref: ref, cx: x, cy: y })));
};
//# sourceMappingURL=CircularThumb.js.map