mirror of
https://github.com/maputnik/editor.git
synced 2026-08-24 22:17:25 +00:00
tabs -> spaces.
This commit is contained in:
@@ -18,12 +18,12 @@ export default class ZoomProperty extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
this.state = {
|
||||||
refs: {}
|
refs: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -31,37 +31,37 @@ export default class ZoomProperty extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We cache a reference for each stop by its index.
|
* We cache a reference for each stop by its index.
|
||||||
*
|
*
|
||||||
* When the stops are reordered the references are also updated (see this.orderStops) this allows React to use the same key for the element and keep keyboard focus.
|
* When the stops are reordered the references are also updated (see this.orderStops) this allows React to use the same key for the element and keep keyboard focus.
|
||||||
*/
|
*/
|
||||||
setStopRefs(props) {
|
setStopRefs(props) {
|
||||||
// This is initialsed below only if required to improved performance.
|
// This is initialsed below only if required to improved performance.
|
||||||
let newRefs;
|
let newRefs;
|
||||||
|
|
||||||
if(props.value && props.value.stops) {
|
if(props.value && props.value.stops) {
|
||||||
props.value.stops.forEach((val, idx) => {
|
props.value.stops.forEach((val, idx) => {
|
||||||
if(!this.state.refs.hasOwnProperty(idx)) {
|
if(!this.state.refs.hasOwnProperty(idx)) {
|
||||||
if(!newRefs) {
|
if(!newRefs) {
|
||||||
newRefs = {...this.state.refs};
|
newRefs = {...this.state.refs};
|
||||||
}
|
}
|
||||||
newRefs[idx] = docUid("stop-");
|
newRefs[idx] = docUid("stop-");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return newRefs;
|
return newRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const newRefs = this.setStopRefs(nextProps);
|
const newRefs = this.setStopRefs(nextProps);
|
||||||
if(newRefs) {
|
if(newRefs) {
|
||||||
this.setState({
|
this.setState({
|
||||||
refs: newRefs
|
refs: newRefs
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order the stops altering the refs to reflect their new position.
|
// Order the stops altering the refs to reflect their new position.
|
||||||
orderStopsByZoom(stops) {
|
orderStopsByZoom(stops) {
|
||||||
@@ -72,7 +72,7 @@ export default class ZoomProperty extends React.Component {
|
|||||||
data: stop
|
data: stop
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Sort by zoom
|
// Sort by zoom
|
||||||
.sort((a, b) => sortNumerically(a.data[0], b.data[0]));
|
.sort((a, b) => sortNumerically(a.data[0], b.data[0]));
|
||||||
|
|
||||||
// Fetch the new position of the stops
|
// Fetch the new position of the stops
|
||||||
|
|||||||
Reference in New Issue
Block a user