Verified isSingleTouch and isMultiTouch functions.
This commit is contained in:
@@ -11,21 +11,21 @@ goog.require('goog.style');
|
|||||||
/**
|
/**
|
||||||
* Determine whether event was caused by a single touch
|
* Determine whether event was caused by a single touch
|
||||||
*
|
*
|
||||||
* @param {Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
ol.event.isSingleTouch = function(evt) {
|
ol.event.isSingleTouch = function(evt) {
|
||||||
return evt.touches && evt.touches.length == 1;
|
return !!(evt.touches && evt.touches.length == 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether event was caused by a multi touch
|
* Determine whether event was caused by a multi touch
|
||||||
*
|
*
|
||||||
* @param {Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
ol.event.isMultiTouch = function(evt) {
|
ol.event.isMultiTouch = function(evt) {
|
||||||
return evt.touches && evt.touches.length > 1;
|
return !!(evt.touches && evt.touches.length > 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ describe("ol.Events", function() {
|
|||||||
events.destroy();
|
events.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has working on() and un() convenience methods", function() {
|
it("has on() and un() convenience methods", function() {
|
||||||
var scope = {}, events = new ol.event.Events("foo");
|
var scope = {}, events = new ol.event.Events("foo");
|
||||||
|
|
||||||
log = [];
|
log = [];
|
||||||
@@ -149,4 +149,16 @@ describe("ol.Events", function() {
|
|||||||
events.destroy();
|
events.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("provides an isSingleTouch() function", function() {
|
||||||
|
expect(ol.event.isSingleTouch({touches: [{}, {}]})).toBe(false);
|
||||||
|
expect(ol.event.isSingleTouch({touches: [{}]})).toBe(true);
|
||||||
|
expect(ol.event.isSingleTouch({})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides an isMultiTouch() function", function() {
|
||||||
|
expect(ol.event.isMultiTouch({touches: [{}, {}]})).toBe(true);
|
||||||
|
expect(ol.event.isMultiTouch({touches: [{}]})).toBe(false);
|
||||||
|
expect(ol.event.isMultiTouch({})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user