@a417420427/use-mouse-distance 中文文档教程
a hook of mouse state by listen mouse event
使用
import { useCallback } from 'react';
import { initialMouseState, useMouseState } from './src';
const Sample = () => {
const [mouseState, setMouseState] = useMouseState(document.body);
const resetState = useCallback(() => {
setMouseState(initialMouseState);
}, [setMouseState]);
return (
<div className="mouse-state">
<button onClick={resetState}>重置</button>
<div className="moveX">x轴方向的移动距离,初始为0: {mouseState.moveX}</div>
<div className="moveX">y轴方向的移动距离,初始为0: {mouseState.moveY}</div>
<div className="moveX">放大倍数,初始值为1: {mouseState.scale}</div>
<div className="moveX">旋转角度,初始为0: {mouseState.rotation}</div>
</div>
);
};
更多
你可能也喜欢
- @2stefant.org/alldays 中文文档教程
- @36node/template-react 中文文档教程
- @44north/release-branch-utilities 中文文档教程
- @51yzone/upload-sdk 中文文档教程
- @aaronflower/jtils 中文文档教程
- @abdigureye/lotide 中文文档教程
- @abhinavrajesh/wordle 中文文档教程
- @accessible/checkbox 中文文档教程
- @acpaas-ui/ngx-embeddable-widgets 中文文档教程
- @activfinancial/cg-api-common 中文文档教程