Wednesday, October 21, 2009

Javascript Tutorial - Draggable View In A Container | Switch on the Code

Javascript Tutorial - Draggable View In A Container | Switch on the Code: "<div id='containerBox' style='position:relative;
border:1px solid black;width:520px;
height:250px;overflow:hidden;' >
<img id='draggableElement' src='duck.jpg'
style='width:1024px;height:1024px;position:absolute;
top:-333px;left:-500px;cursor:move;' />
</div>

<script type='text/javascript'>
var el = document.getElementById('draggableElement');
var parent = el.parentNode;
var leftEdge = parent.clientWidth - el.clientWidth;
var topEdge = parent.clientHeight - el.clientHeight;
var dragObj = new dragObject(el, null,
new Position(leftEdge, topEdge), new Position(0, 0));
</script>"

No comments: