main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
613 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import useHoverDirty from './useHoverDirty';
|
---|
| 2 | import useMouse from './useMouse';
|
---|
| 3 | var nullRef = { current: null };
|
---|
| 4 | var useMouseHovered = function (ref, options) {
|
---|
| 5 | if (options === void 0) { options = {}; }
|
---|
| 6 | var whenHovered = !!options.whenHovered;
|
---|
| 7 | var bound = !!options.bound;
|
---|
| 8 | var isHovered = useHoverDirty(ref, whenHovered);
|
---|
| 9 | var state = useMouse(whenHovered && !isHovered ? nullRef : ref);
|
---|
| 10 | if (bound) {
|
---|
| 11 | state.elX = Math.max(0, Math.min(state.elX, state.elW));
|
---|
| 12 | state.elY = Math.max(0, Math.min(state.elY, state.elH));
|
---|
| 13 | }
|
---|
| 14 | return state;
|
---|
| 15 | };
|
---|
| 16 | export default useMouseHovered;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.