-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathL.Control.MouseScroll.js
44 lines (35 loc) · 1.09 KB
/
L.Control.MouseScroll.js
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
L.Control.MouseScroll = L.Control.Zoom.extend({
options: {
position: "topleft",
mouseScrollText: "Scroll Zoom",
forceSeparateButton: false,
mouseScrollTitle: "Scroll Zoom"
},
onAdd: function (map) {
var scrollZoom = "leaflet-control-scrollzoom"
, container = L.DomUtil.create("div", scrollZoom + " leaflet-bar")
, options = this.options
this._map = map
this._mouseScrollButton = this._createButton(options.mouseScrollText, options.mouseScrollTitle,
scrollZoom, container, this._mouseScroll, this)
this._updateDisabled()
map.on('focus', this._updateDisabled, this)
return container
},
_mouseScroll: function () {
if(this._map.scrollWheelZoom.enabled()) {
this._map.scrollWheelZoom.disable();
}
else {
this._map.scrollWheelZoom.enable();
}
},
_updateDisabled: function () {
var map = this._map
, className = "leaflet-disabled"
L.DomUtil.removeClass(this._mouseScrollButton, className)
if (!map.scrollWheelZoom.enabled()) {
L.DomUtil.addClass(this._mouseScrollButton, className)
}
}
})