react-leaflet-custom-control
Advanced tools
Comparing version
@@ -25,4 +25,9 @@ var __assign = (this && this.__assign) || function () { | ||
var positionClass = ((props.position && POSITION_CLASSES[props.position]) || POSITION_CLASSES.topright); | ||
var controlContainerRef = React.createRef(); | ||
var controlContainerRef = React.useRef(null); | ||
var map = useMap(); | ||
/** | ||
* Whenever the control container ref is created, | ||
* Ensure the click / scroll propagation is removed | ||
* This way click/scroll events do not bubble down to the map | ||
*/ | ||
React.useEffect(function () { | ||
@@ -34,2 +39,7 @@ if (controlContainerRef.current !== null) { | ||
}, [controlContainerRef]); | ||
/** | ||
* Whenever the position is changed, go ahead and get the container of the map and the first | ||
* instance of the position class in that map container | ||
* Fixes #17 | ||
*/ | ||
React.useEffect(function () { | ||
@@ -40,2 +50,6 @@ var mapContainer = map.getContainer(); | ||
}, [positionClass]); | ||
/** | ||
* Whenever the portal root is complete, | ||
* append or prepend the control container to the portal root | ||
*/ | ||
React.useEffect(function () { | ||
@@ -51,3 +65,9 @@ if (portalRoot !== null) { | ||
}, [portalRoot, props.prepend, controlContainerRef]); | ||
/** | ||
* Concatenate the props.container className to the class of the control div | ||
*/ | ||
var className = (((_b = (_a = props.container) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.concat(' ')) || '') + 'leaflet-control'; | ||
/** | ||
* Render | ||
*/ | ||
return (React.createElement("div", __assign({}, props.container, { ref: controlContainerRef, className: className }), props.children)); | ||
@@ -54,0 +74,0 @@ }; |
{ | ||
"name": "react-leaflet-custom-control", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Creates a control wrapper around a React element", | ||
@@ -5,0 +5,0 @@ "main": "lib/Control.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15802
5.28%182
13.04%