onMouseOver() event triggered multiple times
See original GitHub issueI add the mouseover handler to Stage, but found the handler called multiple times even when the mouse pointer is only moving inside the canvas. It’s not like the example: https://konvajs.org/docs/events/Image_Events.html . Any clue?
onMouseOver(e) {
if (e.target.attrs.x === undefined) {
return;
}
let p = this.getPointFromEvent(e);
console.log(p.x);
// alert(p.x);
if (p.x < 0 || p.x > gridX - 1 || p.y < 0 || p.y > gridY - 1) {
return;
}
this.setState({
hoverPiece: {x: p.x, y: p.y}
});
}
render() {
return (
<div>
<Col span={8}>
<Stage width={500} height={300} onClick={this.onClick.bind(this)} onMouseOver={this.onMouseOver.bind(this)} onMouseOut={this.onMouseOut.bind(this)}>
<Layer>
{
this.renderGrid()
}
{/*<Text text="Some text on canvas" fontSize={15} />*/}
{/*<Rect*/}
{/* x={20}*/}
{/* y={50}*/}
{/* width={100}*/}
{/* height={100}*/}
{/* stroke={"black"}*/}
{/* strokeWidth={4}*/}
{/* // fill="red"*/}
{/* // shadowBlur={10}*/}
{/*/>*/}
{
this.renderPieces()
}
{/*<LionImage />*/}
<Line
points={this.getPoints()}
stroke="black"
strokeWidth={10}
/>
{
this.renderHighlight()
}
</Layer>
</Stage>
</Col>
</div>
);
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Mouseover and mouseout trigger multiple times - Stack Overflow
entering means when your cursor enters the bounds of the element. Even when you are in a child node, you are still within...
Read more >Onmouseover/out fireing multiple times? - JavaScript - SitePoint
When I run my mouse over the DIV Object in inquestion, it fire's off several times. Does anyone know what might cause such...
Read more >Javascript – Mouseover and mouseout trigger multiple times
entering means when your cursor enters the bounds of the element. Even when you are in a child node, you are still within...
Read more >onmouseover Event - W3Schools
The onmouseover event occurs when the mouse pointer enters an element. The onmouseover event is often used together with the onmouseout event, which...
Read more >D3 circle pack layout mouseover event is getting triggered ...
... pack layout mouseover event is getting triggered multiple times-d3.js. ... const updateGraph = graphData => { const pack = data => d3.pack()...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can set
listening={false}
to background rectangle. So it doesn’t affect hit regions and events.This is how
mouseover
event works. I think you wantmouseenter
instead.