Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here..I just updated the kineticJs library and used an extra tag .. by courtesy of a friend berry</p> <pre><code> &lt;script src="kinetic-v3.8.0.min.js"&gt; &lt;/script&gt; &lt;script&gt; var stage = null; var groups = { dog: null, bla: null } function setupStage() { stage = new Kinetic.Stage("container", 578, 500); }; function drawImageOnLayer(layer, img) { var x = stage.width / 2 - 100 ; var y = stage.height / 2 - 137 ; var width = 200; var height = 137; var kinecticImg = new Kinetic.Shape(function(){ var context = this.getContext(); context.drawImage(img, x, y, width, height); // draw invisible detectable path for image context.beginPath(); context.rect(x, y, width, height); context.closePath(); }); // enable drag and drop kinecticImg.draggable(true); layer.clear(); layer.add(kinecticImg); layer.draw(); } function drawImageOnLayer2(layer, img) { var x = stage.width / 2 - 300 ; var y = stage.height / 2 - 237 ; var width = 200; var height = 137; var kinecticImg = new Kinetic.Shape(function(){ var context = this.getContext(); context.drawImage(img, x, y, width, height); // draw invisible detectable path for image context.beginPath(); context.rect(x, y, width, height); context.closePath(); }); // enable drag and drop kinecticImg.draggable(true); layer.clear(); layer.add(kinecticImg); layer.draw(); } function loadWithType(type, img) { if (groups[type]) { stage.remove(groups[type]); } groups[type] = new Kinetic.Layer(); stage.add(groups[type]); drawImageOnLayer(groups[type], img); }; function loadWithType2(type, img) { if (groups[type]) { stage.remove(groups[type]); } groups[type] = new Kinetic.Layer(); stage.add(groups[type]); drawImageOnLayer2(groups[type], img); }; &lt;/script&gt; &lt;title&gt;HTMl5 drag drop multiple elements&lt;/title&gt;&lt;/head&gt; &lt;body onload="setupStage();" onmousedown="return false;"&gt; &lt;div id="container"&gt; &lt;/div&gt; &lt;ul id="img"&gt; &lt;li&gt;&lt;a href="#"onclick="loadWithType ('dog',document.getElementById('i1'))"&gt; &lt;img src="dog.png" id="i1" alt="doggie" width="60" height="55"/&gt; &lt;/a&gt;&lt;/li&gt; &lt;li&gt; &lt;a href="#" onclick="loadWithType('dog', document.getElementById('i2'))"&gt; &lt;img src="dog2.png" id="i2" alt="Pulpit rock" width="60" height="55" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ul id="img1"&gt; &lt;li&gt;&lt;a href="#" onclick="loadWithType2('bla', document.getElementById('i4'))"&gt; &lt;img alt="doggie" src="beach.png" id="i4" width="60" height="55" /&gt; &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" onclick="loadWithType2('bla', document.getElementById('i5'))"&gt; &lt;img alt="doggie" src="cat3.png" id="i5" width="60" height="55" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/body&gt; </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.
    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