mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-19 14:57:32 +09:00
30 lines
1.2 KiB
XML
30 lines
1.2 KiB
XML
|
|
<?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>Selection and drag and drop of link inside SVG</title>
|
||
|
|
<a xlink:href="data:text/plain,PASS">
|
||
|
|
<rect x="10" y="10" width="80" height="80" fill="green"/>
|
||
|
|
</a>
|
||
|
|
<textArea x="10" y="100" width="480" height="200" font-size="30">Select part of this text. Once text is selected drag green square above and drop it in the gray box below. 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('svg > 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>
|