Skip to content

Instantly share code, notes, and snippets.

@Dmuasya
Created December 7, 2022 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dmuasya/589f6387ba6ed343dcb1c247e3d83783 to your computer and use it in GitHub Desktop.
Save Dmuasya/589f6387ba6ed343dcb1c247e3d83783 to your computer and use it in GitHub Desktop.
canvas.findTarget = (function(b) {
return function() {
var a = b.apply(this, arguments);
if (a) {
if (this._hoveredTarget !== a) {
canvas.fire('object:over', {
target: a
});
if (this._hoveredTarget) {
canvas.fire('object:out', {
target: this._hoveredTarget
})
}
this._hoveredTarget = a
}
} else if (this._hoveredTarget) {
canvas.fire('object:out', {
target: this._hoveredTarget
});
this._hoveredTarget = null
}
return a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment