-
Notifications
You must be signed in to change notification settings - Fork 177
/
custom-move.html
84 lines (80 loc) · 2.08 KB
/
custom-move.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jquery.pep custom move demo</title>
<!-- Load local jQuery. -->
<script src="../libs/jquery/jquery.js"></script>
<script src="../libs/modernizr.min.js"></script>
<!-- Load local lib and tests. -->
<script src="../src/jquery.pep.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var dragger = $('<div class="dragging"></div>');
var peper = $('.pep').find('.dragger').pep({
place: false,
deferPlacement: true,
velocityMultiplier: 0,
moveTo:function(x, y) {
dragger.css({
left: x,
top: y
});
},
initiate: function(e, pep) {
dragger.css({
top: peper.offset().top,
left: peper.offset().left,
width: peper.width(),
height: peper.height()
}).hide().appendTo(window.document.body).fadeIn(250);
},
stop: function(e, pep) {
peper.fadeOut({
queue: false,
duration: 250,
complete: function() {
peper.stop(1, 1).show();
dragger.fadeOut(150, function(){
dragger.remove();
});
}
}).animate({
top: dragger.offset().top,
left: dragger.offset().left
}, 500);
}
}).end();
});
</script>
<style type="text/css">
.pep{
width: 200px;
height: 200px;
background: blue;
position:absolute;
margin:0;
top:0; left:0;
}
.pep > .dragger {
width:20px; height:20px;
background: red;
position:absolute;
top:0;
right:0;
cursor: move;
}
.dragging {
background:#333;
border-radius:5px;
position:absolute;
}
</style>
</head>
<body>
<div class="pep">
<div class='dragger'>
</div>
</div>
</body>
</html>