Skip to content

Commit 97525ab

Browse files
committed
refactor(EditorMap): move leaflet prototype change outside component
1 parent 565e64c commit 97525ab

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/editor/components/map/EditorMap.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ type State = {
9999
zoomToTarget: boolean
100100
}
101101

102+
// From https://github.com/Leaflet/Leaflet.draw/issues/695#issuecomment-281663243
103+
// Prevents creating a new leaflet draw point on drag
104+
const originalOnTouch = L.Draw.Polyline.prototype._onTouch
105+
L.Draw.Polyline.prototype._onTouch = function (e) {
106+
if (e.originalEvent.pointerType !== 'mouse') {
107+
return originalOnTouch.call(this, e)
108+
}
109+
}
110+
102111
export default class EditorMap extends Component<Props, State> {
103112
state = {
104113
width: 200,
@@ -122,15 +131,6 @@ export default class EditorMap extends Component<Props, State> {
122131
componentDidMount () {
123132
window.addEventListener('resize', this._onResize)
124133
this.setState({willMount: false})
125-
126-
// From https://github.com/Leaflet/Leaflet.draw/issues/695#issuecomment-281663243
127-
// Prevents creating a new leaflet draw point on drag
128-
var originalOnTouch = L.Draw.Polyline.prototype._onTouch
129-
L.Draw.Polyline.prototype._onTouch = function (e) {
130-
if (e.originalEvent.pointerType !== 'mouse') {
131-
return originalOnTouch.call(this, e)
132-
}
133-
}
134134
}
135135

136136
componentWillUnmount () {

0 commit comments

Comments
 (0)