Question: modify the getWordAtLocation() function in the client-side javascript so it too is aware of the width of the word you are trying to drag. function
modify the getWordAtLocation() function in the client-side javascript so it too is aware of the width of the word you are trying to drag. function getWordAtLocation(aCanvasX, aCanvasY)
{
//locate the word near aCanvasX,aCanvasY
//Just use crude region for now. //should be improved to using length of word etc.
//note you will have to click near the start of the word
//as it is implemented now const
TOLERANCE = 50;
for (let i = 0; i < words.length; i++)
{ if (Math.abs(words[i].x - aCanvasX) < TOLERANCE && Math.abs(words[i].y - aCanvasY) < TOLERANCE)
return words[i]
}
return null
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
