mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Fixed #153 with tests
This commit is contained in:
3
dist/js/ionic-angular.js
vendored
3
dist/js/ionic-angular.js
vendored
@ -23095,6 +23095,9 @@ angular.module('ionic.service.gesture', [])
|
||||
return {
|
||||
on: function(eventType, cb, $element) {
|
||||
return window.ionic.onGesture(eventType, cb, $element[0]);
|
||||
},
|
||||
off: function(gesture, eventType, cb) {
|
||||
return window.ionic.offGesture(gesture, eventType, cb);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
4
dist/js/ionic.js
vendored
4
dist/js/ionic.js
vendored
@ -291,8 +291,8 @@ window.ionic = {
|
||||
ionic.on = function() { ionic.EventController.on.apply(ionic.EventController, arguments); };
|
||||
ionic.off = function() { ionic.EventController.off.apply(ionic.EventController, arguments); };
|
||||
ionic.trigger = function() { ionic.EventController.trigger.apply(ionic.EventController.trigger, arguments); };
|
||||
ionic.onGesture = function() { ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
|
||||
ionic.offGesture = function() { ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
|
||||
ionic.onGesture = function() { return ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
|
||||
ionic.offGesture = function() { return ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
|
||||
|
||||
// DISABLING FOR NOW. THE TAP CODE AT THE EXT LEVEL SHOULD BE DOING THIS
|
||||
// Set up various listeners
|
||||
|
||||
3
js/ext/angular/src/service/ionicGesture.js
vendored
3
js/ext/angular/src/service/ionicGesture.js
vendored
@ -4,6 +4,9 @@ angular.module('ionic.service.gesture', [])
|
||||
return {
|
||||
on: function(eventType, cb, $element) {
|
||||
return window.ionic.onGesture(eventType, cb, $element[0]);
|
||||
},
|
||||
off: function(gesture, eventType, cb) {
|
||||
return window.ionic.offGesture(gesture, eventType, cb);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
48
js/ext/angular/test/service/ionicGesture.unit.js
Normal file
48
js/ext/angular/test/service/ionicGesture.unit.js
Normal file
@ -0,0 +1,48 @@
|
||||
describe('Ionic Gesture Service', function() {
|
||||
var gesture;
|
||||
|
||||
beforeEach(module('ionic.service.gesture'));
|
||||
|
||||
beforeEach(inject(function(Gesture) {
|
||||
gesture = Gesture;
|
||||
}));
|
||||
|
||||
iit('Should bind', function() {
|
||||
var el = document.createElement('div');
|
||||
|
||||
var handlers = {
|
||||
dragHandle: function(e) {
|
||||
}
|
||||
};
|
||||
spyOn(handlers, 'dragHandle');
|
||||
gesture.on('drag', handlers.dragHandle, angular.element(el));
|
||||
|
||||
var event = new CustomEvent('drag', { target: el });
|
||||
el.dispatchEvent(event);
|
||||
|
||||
expect(handlers.dragHandle).toHaveBeenCalled();
|
||||
});
|
||||
iit('Should unbind', function() {
|
||||
var el = document.createElement('div');
|
||||
|
||||
var handlers = {
|
||||
dragHandle: function(e) {
|
||||
}
|
||||
};
|
||||
spyOn(handlers, 'dragHandle');
|
||||
|
||||
var g = gesture.on('drag', handlers.dragHandle, angular.element(el));
|
||||
|
||||
var event = new CustomEvent('drag', { target: el });
|
||||
el.dispatchEvent(event);
|
||||
|
||||
expect(handlers.dragHandle).toHaveBeenCalled();
|
||||
|
||||
gesture.off(g, 'drag', handlers.dragHandle);
|
||||
|
||||
var event = new CustomEvent('drag', { target: el });
|
||||
el.dispatchEvent(event);
|
||||
|
||||
expect(handlers.dragHandle).toHaveBeenCalled();
|
||||
});
|
||||
})
|
||||
@ -98,8 +98,8 @@
|
||||
ionic.on = function() { ionic.EventController.on.apply(ionic.EventController, arguments); };
|
||||
ionic.off = function() { ionic.EventController.off.apply(ionic.EventController, arguments); };
|
||||
ionic.trigger = function() { ionic.EventController.trigger.apply(ionic.EventController.trigger, arguments); };
|
||||
ionic.onGesture = function() { ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
|
||||
ionic.offGesture = function() { ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
|
||||
ionic.onGesture = function() { return ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
|
||||
ionic.offGesture = function() { return ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
|
||||
|
||||
// DISABLING FOR NOW. THE TAP CODE AT THE EXT LEVEL SHOULD BE DOING THIS
|
||||
// Set up various listeners
|
||||
|
||||
Reference in New Issue
Block a user