From 580b907b3059eccabc89951f03a50a346960294c Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 24 Aug 2016 10:11:21 -0400 Subject: [PATCH] Fix timers --- modules/behavior/breathe.js | 7 +++--- modules/renderer/map.js | 43 ++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/behavior/breathe.js b/modules/behavior/breathe.js index 583295c0b..93a28e7fb 100644 --- a/modules/behavior/breathe.js +++ b/modules/behavior/breathe.js @@ -1,6 +1,7 @@ import * as d3 from 'd3'; import _ from 'lodash'; -export function Breathe(){ + +export function Breathe() { var duration = 800, selector = '.selected.shadow, .selected .shadow', selected = d3.select(null), @@ -74,7 +75,7 @@ export function Breathe(){ .call(setAnimationParams, fromTo) .duration(duration) .each(function() { ++n; }) - .each('end', function() { + .on('end', function() { if (!--n) { // call once surface.call(run, toFrom); } @@ -96,7 +97,7 @@ export function Breathe(){ breathe.off = function() { done = true; - d3.timer.flush(); + d3.timerFlush(); selected .transition() .call(reset) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 35d18deec..5f4f73472 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -10,15 +10,10 @@ import { fastMouse, setTransform, functor } from '../util/index'; import { flash } from '../ui/index'; export function Map(context) { + var dimensions = [1, 1], dispatch = d3.dispatch('move', 'drawn'), projection = context.projection, - initialTransform = d3.zoomIdentity - .translate(projection.translate()) - .scale(projection.scale() * 2 * Math.PI), - zoom = d3.zoom() - .scaleExtent([1024, 256 * Math.pow(2, 24)]) - .on('zoom', zoomPan), dblclickEnabled = true, redrawEnabled = true, transformStart, @@ -38,6 +33,13 @@ export function Map(context) { mouse, mousemove; + var initialTransform = d3.zoomIdentity + .translate(projection.translate()) + .scale(projection.scale() * 2 * Math.PI), + zoom = d3.zoom() + .scaleExtent([1024, 256 * Math.pow(2, 24)]) + .on('zoom', zoomPan); + var _selection; function map(selection) { @@ -93,22 +95,20 @@ export function Map(context) { if (map.editable() && !transformed) { var hover = d3.event.target.__data__; surface.call(drawVertices.drawHover, context.graph(), hover, map.extent(), map.zoom()); - dispatch.call("drawn", this, {full: false}); + dispatch.call('drawn', this, {full: false}); } }) .on('mouseout.vertices', function() { if (map.editable() && !transformed) { var hover = d3.event.relatedTarget && d3.event.relatedTarget.__data__; surface.call(drawVertices.drawHover, context.graph(), hover, map.extent(), map.zoom()); - dispatch.call("drawn", this, {full: false}); + dispatch.call('drawn', this, {full: false}); } }); - supersurface .call(context.background()); - context.on('enter.map', function() { if (map.editable() && !transformed) { var all = context.intersects(map.extent()), @@ -119,7 +119,7 @@ export function Map(context) { surface .call(drawVertices, graph, all, filter, map.extent(), map.zoom()) .call(drawMidpoints, graph, all, filter, map.trimmedExtent()); - dispatch.call("drawn", this, {full: false}); + dispatch.call('drawn', this, {full: false}); } }); @@ -172,13 +172,13 @@ export function Map(context) { .call(drawLabels, graph, data, filter, dimensions, !difference && !extent) .call(drawPoints, graph, data, filter); - dispatch.call("drawn", this, {full: true}); + dispatch.call('drawn', this, {full: true}); } function editOff() { context.features().resetStats(); surface.selectAll('.layer-osm *').remove(); - dispatch.call("drawn", this, {full: true}); + dispatch.call('drawn', this, {full: true}); } function dblClick() { @@ -189,8 +189,7 @@ export function Map(context) { } function zoomPan(manualEvent) { - return; // TODO - + return // TODO var eventTransform = (manualEvent || d3.event).transform; if (Math.log(event) / Math.LN2 - 8 < minzoom) { @@ -200,7 +199,7 @@ export function Map(context) { .text(t('cannot_zoom')); setZoom(context.minEditableZoom(), true); queueRedraw(); - dispatch.call("move", this, map); + dispatch.call('move', this, map); return; } @@ -216,7 +215,7 @@ export function Map(context) { setTransform(supersurface, tX, tY, scale); queueRedraw(); - dispatch.call("move", this, map); + dispatch.call('move', this, map); } function resetTransform() { @@ -369,7 +368,7 @@ export function Map(context) { if (_selection) { _selection.call(zoom.transform, d3.zoomTransform(_selection).translate(projection.translate())); } - dispatch.call("move", this, map); + dispatch.call('move', this, map); return redraw(); }; @@ -405,7 +404,7 @@ export function Map(context) { } if (setCenter(loc)) { - dispatch.call("move", this, map); + dispatch.call('move', this, map); } return redraw(); @@ -425,7 +424,7 @@ export function Map(context) { } if (setZoom(z)) { - dispatch.call("move", this, map); + dispatch.call('move', this, map); } return redraw(); @@ -445,7 +444,7 @@ export function Map(context) { zoomed = setZoom(z); if (centered || zoomed) { - dispatch.call("move", this, map); + dispatch.call('move', this, map); } return redraw(); @@ -494,7 +493,7 @@ export function Map(context) { map.cancelEase = function() { easing = false; - d3.timer.flush(); + d3.timerFlush(); return map; };