|
1 | 1 | (function (global, factory) { |
2 | 2 | if (typeof define === "function" && define.amd) { |
3 | | - define(['exports', 'react', 'prop-types', '../lib/String'], factory); |
| 3 | + define(["exports", "react", "prop-types", "lodash", "../lib/String"], factory); |
4 | 4 | } else if (typeof exports !== "undefined") { |
5 | | - factory(exports, require('react'), require('prop-types'), require('../lib/String')); |
| 5 | + factory(exports, require("react"), require("prop-types"), require("lodash"), require("../lib/String")); |
6 | 6 | } else { |
7 | 7 | var mod = { |
8 | 8 | exports: {} |
9 | 9 | }; |
10 | | - factory(mod.exports, global.react, global.propTypes, global.String); |
| 10 | + factory(mod.exports, global.react, global.propTypes, global.lodash, global.String); |
11 | 11 | global.Marker = mod.exports; |
12 | 12 | } |
13 | | -})(this, function (exports, _react, _propTypes, _String) { |
14 | | - 'use strict'; |
| 13 | +})(this, function (exports, _react, _propTypes, _lodash, _String) { |
| 14 | + "use strict"; |
15 | 15 |
|
16 | 16 | Object.defineProperty(exports, "__esModule", { |
17 | 17 | value: true |
|
102 | 102 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; |
103 | 103 | } |
104 | 104 |
|
105 | | - var evtNames = ['click', 'dblclick', 'dragend', 'mousedown', 'mouseout', 'mouseover', 'mouseup', 'recenter']; |
| 105 | + var evtNames = ["click", "dblclick", "dragend", "mousedown", "mouseout", "mouseover", "mouseup", "recenter"]; |
106 | 106 |
|
107 | 107 | var wrappedPromise = function wrappedPromise() { |
108 | 108 | var wrappedPromise = {}, |
|
127 | 127 | } |
128 | 128 |
|
129 | 129 | _createClass(Marker, [{ |
130 | | - key: 'componentDidMount', |
| 130 | + key: "componentDidMount", |
131 | 131 | value: function componentDidMount() { |
132 | 132 | this.markerPromise = wrappedPromise(); |
133 | 133 | this.renderMarker(); |
134 | 134 | } |
135 | 135 | }, { |
136 | | - key: 'componentDidUpdate', |
| 136 | + key: "componentDidUpdate", |
137 | 137 | value: function componentDidUpdate(prevProps) { |
138 | | - if (this.props.map !== prevProps.map || this.props.position !== prevProps.position || this.props.icon !== prevProps.icon) { |
| 138 | + if (this.props.map !== prevProps.map || !(0, _lodash.isEqual)(this.props.position, prevProps.position) || !(0, _lodash.isEqual)(this.props.icon, prevProps.icon)) { |
139 | 139 | if (this.marker) { |
140 | 140 | this.marker.setMap(null); |
141 | 141 | } |
142 | 142 | this.renderMarker(); |
143 | 143 | } |
144 | 144 | } |
145 | 145 | }, { |
146 | | - key: 'componentWillUnmount', |
| 146 | + key: "componentWillUnmount", |
147 | 147 | value: function componentWillUnmount() { |
148 | 148 | if (this.marker) { |
149 | 149 | this.marker.setMap(null); |
150 | 150 | } |
151 | 151 | } |
152 | 152 | }, { |
153 | | - key: 'renderMarker', |
| 153 | + key: "renderMarker", |
154 | 154 | value: function renderMarker() { |
155 | 155 | var _this2 = this; |
156 | 156 |
|
|
163 | 163 | label = _props.label, |
164 | 164 | draggable = _props.draggable, |
165 | 165 | title = _props.title, |
166 | | - props = _objectWithoutProperties(_props, ['map', 'google', 'position', 'mapCenter', 'icon', 'label', 'draggable', 'title']); |
| 166 | + props = _objectWithoutProperties(_props, ["map", "google", "position", "mapCenter", "icon", "label", "draggable", "title"]); |
167 | 167 |
|
168 | 168 | if (!google) { |
169 | 169 | return null; |
|
191 | 191 | this.markerPromise.resolve(this.marker); |
192 | 192 | } |
193 | 193 | }, { |
194 | | - key: 'getMarker', |
| 194 | + key: "getMarker", |
195 | 195 | value: function getMarker() { |
196 | 196 | return this.markerPromise; |
197 | 197 | } |
198 | 198 | }, { |
199 | | - key: 'handleEvent', |
| 199 | + key: "handleEvent", |
200 | 200 | value: function handleEvent(evt) { |
201 | 201 | var _this3 = this; |
202 | 202 |
|
203 | 203 | return function (e) { |
204 | | - var evtName = 'on' + (0, _String.camelize)(evt); |
| 204 | + var evtName = "on" + (0, _String.camelize)(evt); |
205 | 205 | if (_this3.props[evtName]) { |
206 | 206 | _this3.props[evtName](_this3.props, _this3.marker, e); |
207 | 207 | } |
208 | 208 | }; |
209 | 209 | } |
210 | 210 | }, { |
211 | | - key: 'render', |
| 211 | + key: "render", |
212 | 212 | value: function render() { |
213 | 213 | return _react2.default.createElement( |
214 | 214 | _react.Fragment, |
215 | 215 | null, |
216 | | - this.props.children && this.marker ? _react2.default.Children.only(_react2.default.cloneElement(this.props.children, { marker: this.marker, |
| 216 | + this.props.children && this.marker ? _react2.default.Children.only(_react2.default.cloneElement(this.props.children, { |
| 217 | + marker: this.marker, |
217 | 218 | google: this.props.google, |
218 | | - map: this.props.map })) : null |
| 219 | + map: this.props.map |
| 220 | + })) : null |
219 | 221 | ); |
220 | 222 | } |
221 | 223 | }]); |
|
233 | 235 | }); |
234 | 236 |
|
235 | 237 | Marker.defaultProps = { |
236 | | - name: 'Marker' |
| 238 | + name: "Marker" |
237 | 239 | }; |
238 | 240 |
|
239 | 241 | exports.default = Marker; |
|
0 commit comments