Skip to content

Commit

Permalink
Merge pull request #216 from eddsaura/fix-negative-values
Browse files Browse the repository at this point in the history
fix negative values when hovering the canvas
  • Loading branch information
timdream authored Nov 10, 2024
2 parents 61e1a11 + 07d4b51 commit 48f3c10
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/wordcloud2.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ if (!window.clearImmediate) {
clientX = evt.clientX
clientY = evt.clientY
}
var eventX = clientX - rect.left

var eventXvalue = clientX - rect.left
var eventX = eventXvalue < 0 ? 0 : eventXvalue
var eventY = clientY - rect.top

var x = Math.floor(eventX * ((canvas.width / rect.width) || 1) / g)
Expand Down

0 comments on commit 48f3c10

Please sign in to comment.