Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
drag(target) {
const index = parseInt(target.parentNode.getAttribute('data-index'), 10);
const { values, onChange } = this.props;
const delta = event.clientY - this.dragStartY;
// a minimum of 8 pixels of mousemovement to start a drag
if (Math.abs(delta) < 8) {
return;
}
const oldValues = values;
let increment = Math.abs(this.dragStartValue * 0.01);
// if it is an integer, minimum increment is 1
let isInteger = false;
if (this.dragStartValue === Math.round(this.dragStartValue)) {
isInteger = true;
increment = Math.max(1, Math.round(increment));
}
return function initResize() {
startX = d3_event.clientX;
startY = d3_event.clientY;
startWidth = target.node().getBoundingClientRect().width;
startHeight = target.node().getBoundingClientRect().height;
d3_select(window)
.on('mousemove.' + eventName, startResize, false)
.on('mouseup.' + eventName, stopResize, false);
};
}
function mousedowned() {
if (touchending || !filter.apply(this, arguments)) return;
var g = gesture(this, arguments, true),
v = select(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
p = mouse(this),
x0 = event.clientX,
y0 = event.clientY;
dragDisable(event.view);
nopropagation();
g.mouse = [p, this.__zoom.invert(p)];
interrupt(this);
g.start();
function mousemoved() {
noevent();
if (!g.moved) {
var dx = event.clientX - x0, dy = event.clientY - y0;
g.moved = dx * dx + dy * dy > clickDistance2;
}
g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = mouse(g.that), g.mouse[1]), g.extent, translateExtent));
}
function mousemoved() {
noevent();
if (!mousemoving) {
var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
mousemoving = dx * dx + dy * dy > clickDistance2;
}
gestures.mouse("drag");
}
function mouseMove() {
const bisectDate = bisector(d => d.date).left;
const x0 = x.invert(mouse(this)[0]);
const pointIndex = bisectDate(lineValuesWithFormat, x0, 1);
const d0 = lineValuesWithFormat[pointIndex - 1];
const d1 = lineValuesWithFormat[pointIndex];
const dxx = x0 - d0.date > d1.date - x0 ? d1 : d0;
showTooltipCallback(dxx, d3_event.clientX + 10, d3_event.clientY + scrollOffset() + 10);
}
.onExchangeMouseMove(() => {
countryTableExchangeTooltip.update(currentEvent.clientX, currentEvent.clientY);
})
.onExchangeMouseOver((d, country, displayByEmissions) => {
function dragOffset() {
if (d3_event.button !== 0) return;
var origin = [d3_event.clientX, d3_event.clientY];
context.container()
.append('div')
.attr('class', 'nudge-surface');
d3_select(window)
.on('mousemove.offset', function() {
var latest = [d3_event.clientX, d3_event.clientY];
var d = [
-(origin[0] - latest[0]) / 4,
-(origin[1] - latest[1]) / 4
];
origin = latest;
nudge(d);
})
startDrag(target) {
const index = parseInt(target.parentNode.getAttribute('data-index'), 10);
const { values } = this.props;
this.dragging = target;
this.dragStartY = event.clientY;
this.dragStartValue = values[index];
}
const highlighter = () => {
const mx = event.clientX;
const my = event.clientY;
const elementMouseIsOver = document.elementFromPoint(mx, my);
highlight(elementMouseIsOver);
};