I've built a small Javascript application which can move an SVG element, i've now tried to rebuild it using image elements for the controls rather than SVG shapes.
Javascript + jQuery
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var panning = false;
var direction;
function startPan(dir){
panning = true;
direction = dir;
}
function stopPan(){
panning = false;
}
function pan(){
var item = $("#moveme");
var x = item.position().left;
var y = item.position().top;
var amount = 1;
if(direction == "left"){
x -= amount;
} else if (direction == "right"){
x += amount ;
} else if (direction == "up"){
y -= amount;
} else if (direction == "down"){
y += amount;
}
item.css("left", x);
item.css("top", y);
}
function panLoop(){
if(panning == true){
pan();
}
}
setInterval(panLoop,100);
});
</script>
<style>
.button:hover{
opacity: 0.5;
}
.button{
position: absolute;
}
.compass{
position: absolute;
}
div.pan{
position: absolute;
width: 90px;
height: 90px;
}
#moveme{
position: absolute;
top: 200px;
left: 200px;
}
</style>
<div class="pan">
<img class="button"
style="top: 0px; left: 30px;"
src="images/tu.png"
onmouseover="startPan('up')"
onmouseout="stopPan()" />
<img class="button"
style="top: 30px; right: 0px;"
src="images/tr.png"
onmouseover="startPan('right')"
onmouseout="stopPan()" />
<img class="button"
style="bottom: 0px; left: 30px;"
src="images/td.png"
onmouseover="startPan('down')"
onmouseout="stopPan()" />
<img class="button"
style="top: 30px; left: 0px;"
src="images/tl.png"
onmouseover="startPan('left')"
onmouseout="stopPan()" />
<img class="compass"
style="top: 21px; left: 21px;"
src="images/c.png"/>
</div>
<div id="moveme">
HELLo
</div>
However it's not calling the mouseover event, and I can't figure out why....
Here is the version using SVG:
Working version using Javascript + SVG
Working version: Working without SVG