blob: 8029734cd83525f6f845d55b828ffae730402d5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="500px" height="500px" viewBox="0 0 500 500">
<title>Drag and drop of animated circle link inside SVG</title>
<a xlink:href="data:text/plain,PASS">
<circle cx="50" cy="50" r="10" fill="green">
<animate attributeName="r" to="50" dur="10s" begin="0s" fill="freeze"/>
</circle>
</a>
<textArea x="10" y="100" width="480" height="200" font-size="30">
Drag green circle above and drop it in the gray box below.
Size of feedback image should match size of circle
and gray box should turn green.</textArea>
<rect x="10" y="300" width="480" height="190" fill="gray"/>
<script type="application/ecmascript">
var a = document.querySelector('a'), rect = document.querySelector('rect');
a.addEventListener('dragstart',
function (event)
{event.dataTransfer.effectAllowed = 'copy'}
,false);
rect.addEventListener('dragenter',
function (event)
{event.preventDefault()}
,false);
rect.addEventListener('dragover',
function (event)
{event.preventDefault()}
,false);
rect.addEventListener('drop',
function (event)
{if(event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,'') == 'data:text/plain,PASS')
{rect.setAttribute('fill','green');}
}
,false);
</script>
</svg>
|