Drag favorite presets buttons out of the top bar to remove

This commit is contained in:
Quincy Morgan
2019-03-05 18:00:00 -05:00
parent a24e2021a2
commit 59cca2a7de
2 changed files with 43 additions and 1 deletions

View File

@@ -491,6 +491,14 @@ button[disabled].action:hover {
padding: 0 5px;
}
.tool-group button.dragging {
opacity: 0.75;
z-index: 200;
}
.tool-group button.dragging .tooltip {
display: none;
}
button.save .count {
display: inline-block;
border: 0px solid #ccc;

View File

@@ -1,6 +1,7 @@
import _debounce from 'lodash-es/debounce';
import { select as d3_select } from 'd3-selection';
import { drag as d3_drag } from 'd3-drag';
import { event as d3_event, select as d3_select } from 'd3-selection';
import {
modeAddArea,
@@ -168,6 +169,39 @@ export function uiModes(context) {
);
}
});
var dragOrigin;
buttonsEnter.call(d3_drag()
.on('start', function(d) {
//if (d3_select(this).classed('disabled')) return;
dragOrigin = {
x: d3_event.x,
y: d3_event.y
};
})
.on('drag', function(d) {
var x = d3_event.x - dragOrigin.x,
y = d3_event.y - dragOrigin.y;
d3_select(this)
.classed('dragging', true)
.style('transform', 'translate(' + x + 'px, ' + y + 'px)');
})
.on('end', function(d) {
d3_select(this)
.style('transform', null)
.classed('dragging', false);
var y = d3_event.y - dragOrigin.y;
if (y > 50) {
// dragged out of the top bar, remove the favorite
context.favoritePreset(d.preset, d.geometry);
}
})
);
/*
buttonsEnter
.append('span')