Note that there are some explanatory texts on larger screens.

plurals
  1. POTooltip is not able to view on Translate position after panning Image on Canvas?
    primarykey
    data
    text
    <p>Following is my Code for reference.</p> <ol> <li>One main image is display on Canvas.</li> <li>On that image with <strong>dataJSON</strong> object I am passing x and y co-ordinates and drawing ball images there.</li> <li>Then tooltip is added. <strong>(function tooltipFunc)</strong></li> <li>But when I am panning image then tooltip is not visible on those balls images on hover.**</li> <li>In <strong>tooltipFunc</strong> function, <strong>if</strong> code is for default position when page loads first time. And <strong>else</strong> code is for translate positions when we are panning the image to show the tooltip.</li> <li>But after panning, when mousehover on balls images then tooltip is not visible. When I click on those ball images then tooltip is visible but not on the translate position.</li> </ol> <p><strong>Any suggestions?</strong></p> <p>//Following is Code for reference</p> <pre><code>var isDown = false; var startCoords = []; var last = [0, 0]; canvas.onmousedown = function(e){ isDown = true; startCoords = [ e.offsetX - last[0], e.offsetY - last[1] ]; }; canvas.onmouseup = function(e){ isDown = false; last = [ e.offsetX - startCoords[0], // set last coordinates e.offsetY - startCoords[1] ]; //tooltipFunc(e); }; canvas.onmousemove = function(e){ tooltipFunc(e); //tooltip function if(!isDown) return; var x = e.offsetX; var y = e.offsetY; context.setTransform(1, 0, 0, 1, x - startCoords[0], y - startCoords[1]); draw1(scaleValue);//redrawing image on canvas while panning image } function tooltipFunc(e){ var translationX, translationY; var r = canvas.getBoundingClientRect(), x = e.clientX - r.left, y = e.clientY - r.top, i = 0, r, inTooltip = false; if((typeof startCoords[0] === 'undefined' || startCoords[0] === 'NaN') &amp;&amp; (typeof startCoords[1] === 'undefined' || startCoords[1] === 'NaN')){ for (; r = dataJSON[i]; i++) { if (x &gt;= parseInt(dataJSON[i].x[0] * scaleValue) + parseInt(scaleValue) &amp;&amp; x &lt;= parseInt(dataJSON[i].x[0] * scaleValue) + parseInt(20/scaleValue) &amp;&amp; y &gt;= parseInt(dataJSON[i].y[0] * scaleValue) &amp;&amp; y &lt;= parseInt(dataJSON[i].y[0] * scaleValue) + parseInt(20/scaleValue)) { clearTooltip(); showTooltip(e.clientX, e.clientY, i); inTooltip = true; } } } else{ for (; r = dataJSON[i]; i++) { translationX = parseInt(x) - parseInt(startCoords[0]); translationY = parseInt(y) - parseInt(startCoords[1]); if (x &gt;= parseInt(dataJSON[i].x[0] * scaleValue) + parseInt(translationX) + parseInt(scaleValue) &amp;&amp; x &lt;= parseInt(dataJSON[i].x[0] * scaleValue) + parseInt(translationX) + parseInt(20/scaleValue) &amp;&amp; y &gt;= parseInt(dataJSON[i].y[0] * scaleValue) + parseInt(translationY) &amp;&amp; y &lt;= parseInt(dataJSON[i].y[0] * scaleValue) + parseInt(translationY) + parseInt(20/scaleValue)) { clearTooltip(); var newX = e.clientX - translationX; var newY = e.clientY - translationY showTooltip(newX, newY, i); inTooltip = true; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload