Skip to content

Commit

Permalink
remove dispatched changes and re-order layers
Browse files Browse the repository at this point in the history
ref #5587
  • Loading branch information
maxgrossman committed Dec 19, 2018
1 parent 3755951 commit 399e778
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions modules/svg/geolocate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { geoMetersToLat } from '../geo';
import _throttle from 'lodash-es/throttle';

export function svgGeolocate(projection, context, dispatch) {
var throttledRedraw = _throttle(function () { dispatch.call('change'); }, 1000);
var layer = d3_select(null);
var _position;

Expand All @@ -22,12 +21,10 @@ export function svgGeolocate(projection, context, dispatch) {


function hideLayer() {
throttledRedraw.cancel();
layer
.transition()
.duration(250)
.style('opacity', 0)
.on('end', function () { });
.style('opacity', 0);
}

function layerOn() {
Expand All @@ -53,7 +50,8 @@ export function svgGeolocate(projection, context, dispatch) {
projectedTangent = projection(tangentLoc),
projectedLoc = projection([loc[0], loc[1]]);

return Math.round(projectedLoc[1] - projectedTangent[1]).toString(); // more south point will have higher pixel value...
// southern most point will have higher pixel value...
return Math.round(projectedLoc[1] - projectedTangent[1]).toString();
}

function update() {
Expand Down Expand Up @@ -131,7 +129,6 @@ export function svgGeolocate(projection, context, dispatch) {
} else {
hideLayer();
}
// dispatch.call('change');
return this;
};

Expand Down
4 changes: 2 additions & 2 deletions modules/svg/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function svgLayers(projection, context) {
{ id: 'mapillary-signs', layer: svgMapillarySigns(projection, context, dispatch) },
{ id: 'openstreetcam-images', layer: svgOpenstreetcamImages(projection, context, dispatch) },
{ id: 'debug', layer: svgDebug(projection, context, dispatch) },
{ id: 'touch', layer: svgTouch(projection, context, dispatch) },
{ id: 'geolocate', layer: svgGeolocate(projection, context, dispatch) }
{ id: 'geolocate', layer: svgGeolocate(projection, context, dispatch) },
{ id: 'touch', layer: svgTouch(projection, context, dispatch) }
];


Expand Down
4 changes: 2 additions & 2 deletions test/spec/svg/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe('iD.svgLayers', function () {
expect(d3.select(nodes[5]).classed('mapillary-signs')).to.be.true;
expect(d3.select(nodes[6]).classed('openstreetcam-images')).to.be.true;
expect(d3.select(nodes[7]).classed('debug')).to.be.true;
expect(d3.select(nodes[8]).classed('touch')).to.be.true;
expect(d3.select(nodes[9]).classed('geolocate')).to.be.true;
expect(d3.select(nodes[8]).classed('geolocate')).to.be.true;
expect(d3.select(nodes[9]).classed('touch')).to.be.true;
});

});

0 comments on commit 399e778

Please sign in to comment.