Disable mode buttons on leading and trailing debounce

This commit is contained in:
Bryan Housel
2017-09-18 22:01:33 -04:00
parent 9fa1b567a0
commit fc9fbbe390

View File

@@ -1,6 +1,7 @@
import * as d3 from 'd3';
import _ from 'lodash';
import { d3keybinding } from '../lib/d3.keybinding.js';
import {
modeAddArea,
modeAddLine,
@@ -53,12 +54,6 @@ export function uiModes(context) {
})
);
context.map()
.on('move.modes', _.debounce(update, 500));
context
.on('enter.modes', update);
buttons
.each(function(d) {
d3.select(this)
@@ -102,6 +97,17 @@ export function uiModes(context) {
.call(keybinding);
var debouncedUpdate = _.debounce(update, 500, { leading: true, trailing: true });
context.map()
.on('move.modes', debouncedUpdate)
.on('drawn.modes', debouncedUpdate);
context
.on('enter.modes', update);
function update() {
selection.selectAll('button.add-button')
.property('disabled', !editable());