Comments (4)
I found how popup's catch the scroll event.
I think this is how you will want to handle scroll events.
import { DomEvent } from 'leaflet'
import React, { Component } from 'react'
import Control from 'react-leaflet-control'
class CustomZoom extends Component {
componentDidMount() {
DomEvent
.disableClickPropagation(this.container)
.disableScrollPropagation(this.container)
}
refContainer(el) {
this.container = el;
}
render() {
<Control position={topright} >
<div ref={::this.refContainer}> I am scrollable, and will not click on the map! </div>
</Control>
}
}
from react-leaflet-control.
If I understand correctly. The control pane is not seeing the scroll event, but the map catches it, and scrolls. I will need to create an example folder to test this. Unfortunately I am traveling today and cannot work on this.
from react-leaflet-control.
Yes, thats exactly what is happening. I have seen suggestions on github leaflet to register an event listener when mouse is entering custom control and to to call map.disablePan() within that event listener. That sounds very hacky to me and did not work reliably for me. What wonders me though is that only few people seem to complain about that issue. I looked into the zoom control code of react-leaflet which seems to block the events somehow but I could not find the reason for that. Thanks for your help in advance !!
from react-leaflet-control.
I tried the code above, but got an Error.
The problem is: React does not guarantee ref callbacks to be called after componentDidMount()
, So there is a chance that this.container()
is still null when componentDidMount()
is called.
Here is my code that eliminated the error for me (plus, no need to bind refContainer
):
class StaticControl extends Component {
constructor(props) {
super(props);
this.container = null;
}
refContainer = (element) => {
this.container = element;
if (element) {
DomEvent
.disableClickPropagation(element)
.disableScrollPropagation(element);
}
}
render() {
return (
<Control position="topleft">
<div ref={this.refContainer}>
I am scrollable and will not click on the map!
</div>
</Control>
);
}
}
from react-leaflet-control.
Related Issues (20)
- onMouseDown events
- When resizing the map and calling invalidateSize() the position of the control changes HOT 1
- compatibility with react v16
- Could not find "store" in either the context or props error while rendering a connected component HOT 5
- Clean unmounting
- why not block event propagation through control to map?
- Fails with latest version of leaflet and react-leaflet HOT 2
- The contents of <Control> do not get rendered on initial <Map> display. HOT 10
- please link to this repo from npm
- Return null always
- undefined is not an object (evaluating 'map._controlCorners') HOT 1
- Could not find declaration file in module 'react-leaflet-contorl' HOT 2
- Legacy API HOT 1
- Crash on startup: `withLeaflet()` is not a function HOT 1
- Can we put up a demo for this?
- Dragging does not work inside control
- Material UI Select Option not Working HOT 1
- Control Rendering underneath Map Tile layer on iOS only HOT 1
- React-Leaflet v3 compatibility HOT 11
- Mark as deprecated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-leaflet-control.