How to implement control with scrollable div?

71 views
Skip to first unread message

Michal Zimmermann

unread,
Nov 16, 2015, 7:39:35 AM11/16/15
to Leaflet
Hi,
I'd like to use a scrollable div inside one of controls that is defined as follows (important parts only). However, when the mousewheel event is triggered, the map starts to scroll and the div remains steady.

I've already tried adding following code into onAdd method. This prevents both the map and the container from scrolling. Is it possible to have a scrollable div inside a control?

L.DomEvent.addListener(container, "mousewheel", function (e) {
                L
.DomEvent.stopPropagation(e);
           
});



my.Infobox = L.Control.extend({
        options
: {
            position
: "bottomleft"
       
},
        onAdd
: function(map) {
           
var container = L.DomUtil.create("div", "vozejkmap-infobox"),
                content
= L.DomUtil.create("div", "vozejkmap-infobox-content", container),
                description
= L.DomUtil.create("div", "vozejkmap-infobox-description", content),
                nearest
= L.DomUtil.create("div", "vozejkmap-infobox-nearest", content),
                button
= L.DomUtil.create("a", "vozejkmap-infobox-close", container);

            L
.DomEvent.disableClickPropagation(container);

            button
.title = "Skrýt infobox";
            button
.innerHTML = "<i class=\"fa fa-lg fa-times\"></i>";

            L
.DomEvent.addListener(button, "click", function(e) {
                map
.removeControl(this);
           
}, this);

           
this._createLocateButton(container);
           
this._map = map;

           
return container;
       
}
   
}
);




CSS

.vozejkmap-infobox {
    background
: white;
    border
: 1px solid #ccc;
    width
: 300px;
    padding
: 5px 20px;
    text
-align: justify;
}

   
.vozejkmap-infobox-content {
        height
: 350px;
        overflow
: auto;
   
}


Michal Zimmermann

unread,
Nov 16, 2015, 8:19:52 AM11/16/15
to leafl...@googlegroups.com
Alright, seems to be a Firefox issue/bug, as Midori works just fine with mousewheel stop propagation.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Leaflet" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leaflet-js/P4DzH2x5foE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Michal Zimmermann (zimmi) 
WWW: http://www.zimmi.cz
Reply all
Reply to author
Forward
0 new messages