-
Notifications
You must be signed in to change notification settings - Fork 177
/
droppable-custom-overlap.html
59 lines (48 loc) · 1.79 KB
/
droppable-custom-overlap.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jquery.pep droppable w/ custom overlap</title>
<!-- Load local jQuery. -->
<script src="../libs/jquery/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<!-- Load local lib and tests. -->
<script src="../src/jquery.pep.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.pep').pep({
droppable: ".droppable",
overlapFunction: function($a, $b){
var rect1 = $a[0].getBoundingClientRect();
var rect2 = $b[0].getBoundingClientRect();
return ( rect2.left > rect1.left &&
rect2.right < rect1.right &&
rect2.top > rect1.top &&
rect2.bottom < rect1.bottom );
},
useCSSTranslation: false
});
});
</script>
<style type="text/css">
.pep{ width: 40px; height: 40px; background: blue; z-index: 10; }
.droppable{ width: 100px; height: 100px;
position: absolute;
border: 5px solid #ccc; }
.droppable.m { top: 50%; left:50%; margin-left: -50px; margin-top: -50px; }
.droppable.tr { right: 30px; bottom: 30px; }
.droppable.br { top: 30px; right: 30px;}
.droppable.bl { top: 30px; left: 30px;}
.droppable.tl { bottom: 30px; left: 30px;}
.pep-dpa { border-color: blue; background: yellow }
</style>
</head>
<body>
<div class="pep"></div>
<div class="droppable m"></div>
<div class="droppable tr"></div>
<div class="droppable br"></div>
<div class="droppable bl"></div>
<div class="droppable tl"></div>
</body>
</html>