Skip to content

Commit e662d81

Browse files
committed
Merge pull request #192 from sorich87/box-cleanup
cleanup box directive in gesture.html
2 parents 8fe6e18 + 5ba7965 commit e662d81

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

js/ext/angular/test/gesture.html

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,44 @@
4949
$element[0].scrollTop = $element[0].scrollHeight;
5050
};
5151

52-
Gesture.on('tap', function(e) {
52+
var tapFn = function(e) {
5353
o('tap', [e.gesture.touches[0].pageX, e.gesture.touches[0].pageY]);
54-
}, $element);
54+
};
55+
var tapGesture = Gesture.on('tap', tapFn, $element);
5556

56-
Gesture.on('release', function(e) {
57+
var releaseFn = function(e) {
5758
o('release', [e.gesture.touches[0].pageX, e.gesture.touches[0].pageY]);
58-
}, $element);
59+
};
60+
var releaseGesture = Gesture.on('release', releaseFn, $element);
5961

60-
Gesture.on('hold', function(e) {
62+
var holdFn = function(e) {
6163
o('hold', [e.gesture.touches[0].pageX, e.gesture.touches[0].pageY]);
62-
}, $element);
64+
};
65+
var holdGesture = Gesture.on('hold', holdFn, $element);
6366

64-
Gesture.on('drag', function(e) {
67+
var dragFn = function(e) {
6568
o('drag', [e.gesture.touches[0].pageX, e.gesture.touches[0].pageY, e.gesture.deltaX, e.gesture.deltaY]);
66-
}, $element);
69+
};
70+
var dragGesture = Gesture.on('drag', dragFn, $element);
6771

68-
Gesture.on('swipe', function(e) {
72+
var swipeFn = function(e) {
6973
o('swipe', [e.gesture.touches[0].pageX, e.gesture.touches[0].pageY, e.gesture.direction]);
70-
}, $element);
74+
};
75+
var swipeGesture = Gesture.on('swipe', swipeFn, $element);
7176

72-
Gesture.on('transform', function(e) {
77+
var transformFn = function(e) {
7378
o('transform', [e.gesture.touches[0].pageX, e.gesture.touches[0].pageY, e.gesture.direction]);
74-
}, $element);
79+
};
80+
var transformGesture = Gesture.on('transform', transformFn, $element);
81+
82+
$scope.$on('$destroy', function () {
83+
Gesture.off(dragGesture, 'drag', dragFn);
84+
Gesture.off(holdGesture, 'hold', holdFn);
85+
Gesture.off(releaseGesture, 'release', releaseFn);
86+
Gesture.off(swipeGesture, 'swipe', swipeFn);
87+
Gesture.off(tapGesture, 'tap', tapFn);
88+
Gesture.off(transformGesture, 'transform', transformFn);
89+
});
7590
}
7691
};
7792
});

0 commit comments

Comments
 (0)