Skip to content

@wallin /multiple_touchdrag.html
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Multiple drag n' drop for touch
<html>
<head>
<meta charset=utf-8 />
<title>Drag n' drop touch demo - sewa.se</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style type="text/css">
.draggable {
position: absolute;
left: 30px;
top: 30px;
width: 60px;
height: 60px;
margin-left: -30px;
margin-top: -30px;
color: #FFF;
font: bold 16px Helvetica,Arial,Sans-serif;
text-align: center;
background-color: #ABF;
border: 3px solid #669;
}
</style>
</head>
<body>
<div class="draggable">Drag me!</div>
<div class="draggable">Drag me!</div>
</body>
<script type="text/javascript">
var moveMe = function(e) {
e.preventDefault();
var orig = e.originalEvent;
$(this).css({
top: orig.changedTouches[0].pageY,
left: orig.changedTouches[0].pageX
});
};
$(".draggable").bind("touchstart touchmove", moveMe);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.