Note that there are some explanatory texts on larger screens.

plurals
  1. PODragging and dropping images within multiple boundries in HTML5 canvas
    primarykey
    data
    text
    <p>I am new with HTML5. I have to implement such a functionality that I want images to be dropped within a canvas from outside, then there are visible boundaries within canvas and the images can be moved from one boundary to another. It is the same as in the following link, <a href="http://custom.case-mate.com/diy?bypassLandingPage=true" rel="nofollow">http://custom.case-mate.com/diy?bypassLandingPage=true</a></p> <p>As, in the site, user selects the pattern and drags images into that. Then he can drag the images between the boundaries. please give some solution for implementing such a functionality. </p> <p>Here is what I have tried,</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; body { margin: 0px; padding: 0px; } canvas {position:relative; left:150%; border: 10px solid #9C9898; background-color: grey; } &lt;/style&gt; &lt;script src="http://www.html5canvastutorials.com/libraries/kinetic-v3.10.0.js"&gt;&lt;/script&gt; &lt;script&gt; window.onload = function() { var stage = new Kinetic.Stage({ container: "container", width: 300, height: 400, }); var layer = new Kinetic.Layer(); var redLine = new Kinetic.Line({ points: [150, 0, 150, 400], stroke: "white", strokeWidth: 2, }); var blueLine = new Kinetic.Line({ points: [150, 0, 150, 120, 300, 120], stroke: "white", strokeWidth: 2, }); var thirdLine = new Kinetic.Line({ points: [300, 120, 150, 120, 150, 400], stroke: "white", strokeWidth: 2, }); var imageObj = new Image(); imageObj.onload = function() { var image = new Kinetic.Image({ x: stage.getWidth() / 2 - 50, y: stage.getHeight() / 2 - 60, image: imageObj, width: 100, height: 120, }); image.draggable(true); layer.add(image); // add the layer to the stage stage.add(layer); }; imageObj.src = "images/212.png"; layer.add(redLine); layer.add(blueLine); layer.add(thirdLine); stage.add(layer); }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </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.
 

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