Accessibility - now we can use the keyboard to zoom in and out.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
goog.provide('ol.control.Zoom');
|
goog.provide('ol.control.Zoom');
|
||||||
|
|
||||||
|
goog.require('ol.event');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
|
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
|
|
||||||
|
|
||||||
@@ -58,7 +60,8 @@ ol.control.Zoom.prototype.setMap = function(map) {
|
|||||||
ol.control.Zoom.prototype.activate = function() {
|
ol.control.Zoom.prototype.activate = function() {
|
||||||
var active = goog.base(this, 'activate');
|
var active = goog.base(this, 'activate');
|
||||||
if (active) {
|
if (active) {
|
||||||
this.map_.getEvents().register("click", this.handle, this);
|
this.map_.getEvents().register('click', this.handle, this);
|
||||||
|
this.map_.getEvents().register('keypress', this.handle, this);
|
||||||
}
|
}
|
||||||
return active;
|
return active;
|
||||||
};
|
};
|
||||||
@@ -67,7 +70,8 @@ ol.control.Zoom.prototype.activate = function() {
|
|||||||
ol.control.Zoom.prototype.deactivate = function() {
|
ol.control.Zoom.prototype.deactivate = function() {
|
||||||
var inactive = goog.base(this, 'deactivate');
|
var inactive = goog.base(this, 'deactivate');
|
||||||
if (inactive) {
|
if (inactive) {
|
||||||
this.map_.getEvents().unregister("click", this.handle, this);
|
this.map_.getEvents().unregister('click', this.handle, this);
|
||||||
|
this.map_.getEvents().unregister('keypress', this.handle, this);
|
||||||
}
|
}
|
||||||
return inactive;
|
return inactive;
|
||||||
};
|
};
|
||||||
@@ -78,16 +82,15 @@ ol.control.Zoom.prototype.deactivate = function() {
|
|||||||
ol.control.Zoom.prototype.handle = function(evt) {
|
ol.control.Zoom.prototype.handle = function(evt) {
|
||||||
var target = /** @type {Node} */ (evt.target),
|
var target = /** @type {Node} */ (evt.target),
|
||||||
handled = false;
|
handled = false;
|
||||||
if (goog.dom.getAncestorByClass(target, ol.control.Zoom.RES.IN_CLS)) {
|
if (evt.type === 'click' || ol.event.isEnterOrSpace(evt)) {
|
||||||
this.map_.zoomIn();
|
if (goog.dom.getAncestorByClass(target, ol.control.Zoom.RES.IN_CLS)) {
|
||||||
handled = true;
|
this.map_.zoomIn();
|
||||||
} else
|
handled = true;
|
||||||
if (goog.dom.getAncestorByClass(target, ol.control.Zoom.RES.OUT_CLS)) {
|
} else
|
||||||
this.map_.zoomOut();
|
if (goog.dom.getAncestorByClass(target, ol.control.Zoom.RES.OUT_CLS)) {
|
||||||
handled = true;
|
this.map_.zoomOut();
|
||||||
}
|
handled = true;
|
||||||
if (handled) {
|
}
|
||||||
evt.preventDefault();
|
|
||||||
}
|
}
|
||||||
return !handled;
|
return !handled;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user