我正在尝试将SVG元素移动5像素,这是我的功能:
onMouseMove = (e) => {
const xDiff = this.coords.x - e.clientX;
const yDiff = this.coords.y - e.clientY;
let movex = this.state.x - xDiff;
let movey = this.state.y - yDiff;
while ( !(movex % 5) ) {
movex++;
}
while ( !(movey % 5) ) {
movey++;
}
this.setState({
x: movex,
y: movey,
});
我如何产生这种效果?