Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding dist/components for polygon and polyline with propChanged() fu…
…nction
  • Loading branch information
Sam Selfridge Sam Selfridge
Sam Selfridge authored and Sam Selfridge committed Apr 27, 2019
commit 6c7a7dd9ea7aef53b4a076829db6944d33f8cf43
21 changes: 15 additions & 6 deletions dist/components/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
if (this.props.map !== prevProps.map || !(0, _arePathsEqual.arePathsEqual)(this.props.paths, prevProps.paths)) {
if (this.propsChanged(prevProps) || this.props.map !== prevProps.map || !(0, _arePathsEqual.arePathsEqual)(this.props.paths, prevProps.paths)) {
if (this.polygon) {
this.polygon.setMap(null);
}
Expand All @@ -149,10 +149,19 @@
this.polygon.setMap(null);
}
}
}, {
key: 'propsChanged',
value: function propsChanged(newProps) {
var _this2 = this;

return Object.keys(Polygon.propTypes).some(function (key) {
return _this2.props[key] !== newProps[key];
});
}
}, {
key: 'renderPolygon',
value: function renderPolygon() {
var _this2 = this;
var _this3 = this;

var _props = this.props,
map = _props.map,
Expand Down Expand Up @@ -182,7 +191,7 @@
this.polygon = new google.maps.Polygon(params);

evtNames.forEach(function (e) {
_this2.polygon.addListener(e, _this2.handleEvent(e));
_this3.polygon.addListener(e, _this3.handleEvent(e));
});

this.polygonPromise.resolve(this.polygon);
Expand All @@ -195,12 +204,12 @@
}, {
key: 'handleEvent',
value: function handleEvent(evt) {
var _this3 = this;
var _this4 = this;

return function (e) {
var evtName = 'on' + (0, _String.camelize)(evt);
if (_this3.props[evtName]) {
_this3.props[evtName](_this3.props, _this3.polygon, e);
if (_this4.props[evtName]) {
_this4.props[evtName](_this4.props, _this4.polygon, e);
}
};
}
Expand Down
21 changes: 15 additions & 6 deletions dist/components/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
if (this.props.map !== prevProps.map || !(0, _arePathsEqual.arePathsEqual)(this.props.path, prevProps.path)) {
if (this.propsChanged(prevProps) || this.props.map !== prevProps.map || !(0, _arePathsEqual.arePathsEqual)(this.props.path, prevProps.path)) {
if (this.polyline) {
this.polyline.setMap(null);
}
Expand All @@ -149,10 +149,19 @@
this.polyline.setMap(null);
}
}
}, {
key: 'propsChanged',
value: function propsChanged(newProps) {
var _this2 = this;

return Object.keys(Polyline.propTypes).some(function (key) {
return _this2.props[key] !== newProps[key];
});
}
}, {
key: 'renderPolyline',
value: function renderPolyline() {
var _this2 = this;
var _this3 = this;

var _props = this.props,
map = _props.map,
Expand All @@ -178,7 +187,7 @@
this.polyline = new google.maps.Polyline(params);

evtNames.forEach(function (e) {
_this2.polyline.addListener(e, _this2.handleEvent(e));
_this3.polyline.addListener(e, _this3.handleEvent(e));
});

this.polylinePromise.resolve(this.polyline);
Expand All @@ -191,12 +200,12 @@
}, {
key: 'handleEvent',
value: function handleEvent(evt) {
var _this3 = this;
var _this4 = this;

return function (e) {
var evtName = 'on' + (0, _String.camelize)(evt);
if (_this3.props[evtName]) {
_this3.props[evtName](_this3.props, _this3.polyline, e);
if (_this4.props[evtName]) {
_this4.props[evtName](_this4.props, _this4.polyline, e);
}
};
}
Expand Down