Dynamically change draggable property.
See original GitHub issueI need to dynamically switch the draggable property.
The case
There are a marker and an infoWindow as custom react components. onMouseDown
event on the infoWindow the map’s property draggable has to be false and on onMouseUp
becomes true.
Actually, this is not a problem to do. I added to the InfoWindow component function that calls to the parent component (the map) and rerender draggable property changes to the one that I need. If output to the console isDragAllow
property at the time of rendering, it is the value that I need.
The Map component looks like that.
<GoogleMap draggable={ this.state.isDragAllow }>{ Markers }</GoogleMap>
The problem
Although the value of which I bring to the console such as I need to, in fact, until I move cursor out of the infoWindow remains the possibility of drag. In other words, when onMouseDown
fires and till cursor is above the infoWindow isDragAllow
is still true.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Haha ok @vilkoalexander! Glad you worked it out! Let me know if you need further help!
I’m having the same problem, except that the
draggable
behavior never seems to change. I’m toggling the value of the prop (successfully) with a button outside of the component, but the map stays draggable even when the prop isfalse
. Is there any way to get the behavior to update?