From 050907e2525ed0dd037f380b4dd84e6d0cebea3e Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 15 Feb 2018 08:27:39 -0500 Subject: [PATCH] Move event bindings to update selection, so callbacks use correct vars When they are on the enter selection, they can stay "sticky" which has the effect where you might move a slider and it puts the intersection back to how it previously was (or returns to a previous intersection) --- modules/ui/fields/restrictions.js | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 9581d42dd..bebbff44b 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -157,7 +157,15 @@ export function uiFieldRestrictions(field, context) { .attr('type', 'range') .attr('min', '20') .attr('max', '50') - .attr('step', '5') + .attr('step', '5'); + + distControlEnter + .append('span') + .attr('class', 'restriction-distance-text'); + + // update + selection.selectAll('.restriction-distance-input') + .property('value', _maxDistance) .on('input', function() { var val = d3_select(this).property('value'); _maxDistance = +val; @@ -167,14 +175,6 @@ export function uiFieldRestrictions(field, context) { _parent.call(restrictions); }); - distControlEnter - .append('span') - .attr('class', 'restriction-distance-text'); - - // update - selection.selectAll('.restriction-distance-input') - .property('value', _maxDistance); - var distDisplay; if (isImperial) { // imprecise conversion for prettier display var distToFeet = { @@ -210,14 +210,7 @@ export function uiFieldRestrictions(field, context) { .attr('type', 'range') .attr('min', '0') .attr('max', '2') - .attr('step', '1') - .on('input', function() { - var val = d3_select(this).property('value'); - _maxViaWay = +val; - _container.selectAll('.layer-osm .layer-turns *').remove(); - context.storage('turn-restriction-via-way', _maxViaWay); - _parent.call(restrictions); - }); + .attr('step', '1'); viaControlEnter .append('span') @@ -225,7 +218,14 @@ export function uiFieldRestrictions(field, context) { // update selection.selectAll('.restriction-via-way-input') - .property('value', _maxViaWay); + .property('value', _maxViaWay) + .on('input', function() { + var val = d3_select(this).property('value'); + _maxViaWay = +val; + _container.selectAll('.layer-osm .layer-turns *').remove(); + context.storage('turn-restriction-via-way', _maxViaWay); + _parent.call(restrictions); + }); var t = ['Node only', 'Up to 1 way', 'Up to 2 ways']; selection.selectAll('.restriction-via-way-text')