From 07d4b51339fc9007688201e6d57ae57f121f6685 Mon Sep 17 00:00:00 2001 From: Jose Saura Date: Thu, 31 Oct 2024 11:17:22 +0100 Subject: [PATCH] fix negative values --- src/wordcloud2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wordcloud2.js b/src/wordcloud2.js index c4a607b..9ed6be3 100644 --- a/src/wordcloud2.js +++ b/src/wordcloud2.js @@ -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)