forked from mcasimir/mobile-angular-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrag.html
83 lines (80 loc) · 2.23 KB
/
drag.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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0" />
<title>Limiting $drag movement</title>
<link rel="stylesheet" href="/dist/css/mobile-angular-ui-base.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.min.js"></script>
<script src="/dist/js/mobile-angular-ui.min.js"></script>
<script src="/dist/js/mobile-angular-ui.gestures.min.js"></script>
<style id='example-css'>
.viewport {
height: 100%;
width: 100%;
padding: 40px;
}
.drag-area {
height: 100%;
width: 100%;
border: 1px solid #444;
position: relative;
}
.drag-me {
height: 100px;
width: 100px;
border-radius: 200px;
position: absolute;
top: 50%;
left: 50%;
margin: -50px auto auto -50px;
-webkit-transition: -webkit-transform 500ms;
-ms-transition: -ms-transform 500ms;
-moz-transition: -moz-transform 500ms;
transition: transform 500ms;
background-color: #d9edf7;
border: 1px solid #31708f;
color: #31708f;
line-height: 95px;
font-size: 30px;
text-align: center;
box-shadow: 1px 1px 1px #ccc;
text-shadow: 1px 1px #fff;
}
</style>
<script>
app = angular.module('myApp', ['mobile-angular-ui', 'mobile-angular-ui.gestures']);
</script>
<script id='example-js'>
app.directive('dragMe', ['$drag', function($drag){
return {
controller: function($scope, $element) {
$drag.bind($element,
{
// limit movement of element to its parent
transform: $drag.TRANSLATE_INSIDE($element.parent()),
end: function(drag) {
// go back to initial position
drag.reset();
}
},
{ // release touch when movement is outside bounduaries
sensitiveArea: $element.parent()
}
);
}
};
}]);
</script>
</head>
<body ng-app="myApp" id='example-html'>
<div class='viewport'>
<div class='drag-area'>
<div drag-me class='drag-me'>
<i class='fa fa-arrows'></i>
</div>
</div>
</div>
</body>
</html>