Note that there are some explanatory texts on larger screens.

plurals
  1. POKineticJS mouse event issue
    primarykey
    data
    text
    <p>I'm trying to make some kind of interactive map with KineticJS, where hovered places make other images to load. But i can't make mouse events work properly. Thing is, everything works fine <strong>but only with first mouseover</strong> attempt, and when i hover second time, <strong>mouseout</strong> trigger don't work :(</p> <p><strong>i.e. When i do "mouseout" second time, i want map part to be light blue again (n_amer image), but it remeins dark blue (n_amer_sel image).</strong></p> <p>Here is the link where you can see this bug: <a href="http://kinlibtst.elitno.net/" rel="nofollow">http://kinlibtst.elitno.net/</a></p> <p>I would be very grateful for the help!</p> <p>Code:</p> <pre><code> function loadImages(sources, callback) { var assetDir = 'PROJECT/'; var images = {}; var loadedImages = 0; var numImages = 0; for(var src in sources) { numImages++; } for(var src in sources) { images[src] = new Image(); images[src].onload = function() { if(++loadedImages &gt;= numImages) { callback(images); } }; images[src].src = assetDir + sources[src]; } } function initStage(images) { var stage = new Kinetic.Stage({ container: 'container', width: 900, height: 452 }); var imagesLayer = new Kinetic.Layer(); // img vars var n_amer = new Kinetic.Image({ image: images.n_amer, x: 0, y: 0 }); var n_amer_sel = new Kinetic.Image({ image: images.n_amer_sel, x: 0, y: 0 }); // mouse events n_amer.on('mouseover', function() { imagesLayer.add(n_amer_sel) stage.draw(); }); n_amer_sel.on('mouseout', function() { imagesLayer.remove(n_amer_sel); stage.draw(); }); // imageBuffer for transparent pixels n_amer.createImageBuffer(function() { imagesLayer.drawBuffer(); }); n_amer_sel.createImageBuffer(function() { imagesLayer.drawBuffer(); }); // add to stage imagesLayer.add(n_amer); stage.add(imagesLayer); } window.onload = function() { var sources = { n_amer: 'N-Amer.png', n_amer_sel: 'N-Amer_sel.png' }; loadImages(sources, initStage); }; </code></pre>
    singulars
    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.
    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