Skip to content

Commit

Permalink
fix(Marker): event listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed Oct 25, 2014
1 parent 556b9be commit f878c00
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,30 @@ module.exports = React.createClass({
},

componentDidMount () {
var {marker} = this.state;
if (marker || !this.context.hasMap()) return;
this.add_listeners(this._init_marker());
var marker = this._init_marker();
console.log("componentDidMount", marker);
if (!marker) return;
this.add_listeners(marker);
},

componentWillUpdate () {
var {marker} = this.state;
if (marker || !this.context.hasMap()) return;
if (!marker) return;
this.clear_listeners(marker);
},

componentDidUpdate () {
var {marker} = this.state;
if (!this.context.hasMap()) return;
if (marker) {
marker.setOptions(this.props);
} else {
this.add_listeners(this._init_marker());
}
var marker = this._init_marker();
if (!marker) return;
this.add_listeners(marker);
marker.setOptions(this.props);
},

componentWillUnmount () {
var {marker} = this.state;
if (marker || !this.context.hasMap()) return;
if (!marker) return;
this.clear_listeners(marker);
marker.setMap(null);
},

render () {
Expand All @@ -54,11 +53,12 @@ module.exports = React.createClass({

_init_marker () {
var {context} = this;
if (this.state.marker || !context.hasMap() || !context.getApi()) {
return;
var {marker} = this.state;
if (marker || !context.hasMap() || !context.getApi()) {
return marker;
}
var {Marker} = context.getApi();
var marker = new Marker(this.props);
marker = new Marker(this.props);
marker.setMap(context.getMap());

this.expose_getters_from(Marker.prototype, marker);
Expand Down

0 comments on commit f878c00

Please sign in to comment.