main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
805 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var tslib_1 = require("tslib");
|
---|
4 | var useHoverDirty_1 = tslib_1.__importDefault(require("./useHoverDirty"));
|
---|
5 | var useMouse_1 = tslib_1.__importDefault(require("./useMouse"));
|
---|
6 | var nullRef = { current: null };
|
---|
7 | var useMouseHovered = function (ref, options) {
|
---|
8 | if (options === void 0) { options = {}; }
|
---|
9 | var whenHovered = !!options.whenHovered;
|
---|
10 | var bound = !!options.bound;
|
---|
11 | var isHovered = useHoverDirty_1.default(ref, whenHovered);
|
---|
12 | var state = useMouse_1.default(whenHovered && !isHovered ? nullRef : ref);
|
---|
13 | if (bound) {
|
---|
14 | state.elX = Math.max(0, Math.min(state.elX, state.elW));
|
---|
15 | state.elY = Math.max(0, Math.min(state.elY, state.elH));
|
---|
16 | }
|
---|
17 | return state;
|
---|
18 | };
|
---|
19 | exports.default = useMouseHovered;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.