Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
distY -= horizontalInfo.offset;
}
datas.passDistX = distX;
datas.passDistY = distY;
const beforeTranslate = plus(getDragDist({ datas, distX, distY }, true), startTranslate);
const translate = plus(getDragDist({ datas, distX, distY }, false), startTranslate);
if (!isSnap) {
throttleArray(translate, throttleDrag);
throttleArray(beforeTranslate, throttleDrag);
}
const beforeDist = minus(beforeTranslate, startTranslate);
const dist = minus(translate, startTranslate);
const delta = minus(dist, prevDist);
const beforeDelta = minus(beforeDist, prevBeforeDist);
datas.prevDist = dist;
datas.prevBeforeDist = beforeDist;
const left = datas.left + beforeDist[0];
const top = datas.top + beforeDist[1];
const right = datas.right - beforeDist[0];
const bottom = datas.bottom - beforeDist[1];
const nextTransform = `${transform} translate(${dist[0]}px, ${dist[1]}px)`;
if (!parentEvent && !parentMoveable && delta.every(num => !num) && beforeDelta.some(num => !num)) {
return;
}
const params = fillParams(moveable, e, {
transform: nextTransform,
dist,
const rectTop = rect.top - containerRect.top + container.scrollTop;
const rectWidth = rect.width;
const rectHeight = rect.height;
const mat = multiplies(
n,
beforeMatrix,
absoluteMatrix,
);
const {
left: prevLeft,
top: prevTop,
width: prevWidth,
height: prevHeight,
} = caculateRect(mat, width, height, n);
const posOrigin = caculatePosition(mat, origin, n);
const prevOrigin = minus(posOrigin, [prevLeft, prevTop]);
const rectOrigin = [
rectLeft + prevOrigin[0] * rectWidth / prevWidth,
rectTop + prevOrigin[1] * rectHeight / prevHeight,
];
const offset = [0, 0];
let count = 0;
while (++count < 10) {
const inverseBeforeMatrix = invert(beforeMatrix, n);
[offset[0], offset[1]] = minus(
caculatePosition(inverseBeforeMatrix, rectOrigin, n),
caculatePosition(inverseBeforeMatrix, posOrigin, n),
);
const mat2 = multiplies(
n,
beforeMatrix,
isSnap = verticalInfo.isSnap || horizontalInfo.isSnap;
distX -= verticalInfo.offset;
distY -= horizontalInfo.offset;
}
datas.passDistX = distX;
datas.passDistY = distY;
const beforeTranslate = plus(getDragDist({ datas, distX, distY }, true), startTranslate);
const translate = plus(getDragDist({ datas, distX, distY }, false), startTranslate);
if (!isSnap) {
throttleArray(translate, throttleDrag);
throttleArray(beforeTranslate, throttleDrag);
}
const beforeDist = minus(beforeTranslate, startTranslate);
const dist = minus(translate, startTranslate);
const delta = minus(dist, prevDist);
const beforeDelta = minus(beforeDist, prevBeforeDist);
datas.prevDist = dist;
datas.prevBeforeDist = beforeDist;
const left = datas.left + beforeDist[0];
const top = datas.top + beforeDist[1];
const right = datas.right - beforeDist[0];
const bottom = datas.bottom - beforeDist[1];
const nextTransform = `${transform} translate(${dist[0]}px, ${dist[1]}px)`;
if (!parentEvent && !parentMoveable && delta.every(num => !num) && beforeDelta.some(num => !num)) {
return;
}
const n = is3d ? 4 : 3;
const nextOrigin = caculateTransformOrigin(
transformOrigin!,
width,
height,
prevWidth,
prevHeight,
prevOrigin,
);
const groupLeft = groupable ? left : 0;
const groupTop = groupable ? top : 0;
const nextMatrix = getNextMatrix(offsetMatrix, targetMatrix, nextOrigin, n);
const dist = getDist(fixedPosition, nextMatrix, width, height, n, direction);
return minus(dist, [groupLeft, groupTop]);
}
export function getStartDirection(
distX -= verticalInfo.offset;
distY -= horizontalInfo.offset;
}
datas.passDistX = distX;
datas.passDistY = distY;
const beforeTranslate = plus(getDragDist({ datas, distX, distY }, true), startTranslate);
const translate = plus(getDragDist({ datas, distX, distY }, false), startTranslate);
if (!isSnap) {
throttleArray(translate, throttleDrag);
throttleArray(beforeTranslate, throttleDrag);
}
const beforeDist = minus(beforeTranslate, startTranslate);
const dist = minus(translate, startTranslate);
const delta = minus(dist, prevDist);
const beforeDelta = minus(beforeDist, prevBeforeDist);
datas.prevDist = dist;
datas.prevBeforeDist = beforeDist;
const left = datas.left + beforeDist[0];
const top = datas.top + beforeDist[1];
const right = datas.right - beforeDist[0];
const bottom = datas.bottom - beforeDist[1];
const nextTransform = `${transform} translate(${dist[0]}px, ${dist[1]}px)`;
if (!parentEvent && !parentMoveable && delta.every(num => !num) && beforeDelta.some(num => !num)) {
return;
}
const params = fillParams(moveable, e, {
transform: nextTransform,
(child, childDatas, eventParams) => {
const { left, top, beforeOrigin } = child.state;
const childClient = plus(
minus([left, top], [parentLeft, parentTop]),
minus(beforeOrigin, parentBeforeOrigin),
);
childDatas.prevClient = childClient;
eventParams.dragStart = Draggable.dragStart(
child,
new CustomDragger().dragStart(childClient, inputEvent),
);
},
);
isSnap = verticalInfo.isSnap || horizontalInfo.isSnap;
distX -= verticalInfo.offset;
distY -= horizontalInfo.offset;
}
datas.passDistX = distX;
datas.passDistY = distY;
const beforeTranslate = plus(getDragDist({ datas, distX, distY }, true), startTranslate);
const translate = plus(getDragDist({ datas, distX, distY }, false), startTranslate);
if (!isSnap) {
throttleArray(translate, throttleDrag);
throttleArray(beforeTranslate, throttleDrag);
}
const beforeDist = minus(beforeTranslate, startTranslate);
const dist = minus(translate, startTranslate);
const delta = minus(dist, prevDist);
const beforeDelta = minus(beforeDist, prevBeforeDist);
datas.prevDist = dist;
datas.prevBeforeDist = beforeDist;
const left = datas.left + beforeDist[0];
const top = datas.top + beforeDist[1];
const right = datas.right - beforeDist[0];
const bottom = datas.bottom - beforeDist[1];
const nextTransform = `${transform} translate(${dist[0]}px, ${dist[1]}px)`;
if (!parentEvent && !parentMoveable && delta.every(num => !num) && beforeDelta.some(num => !num)) {
return;
}
const params = fillParams(moveable, e, {
top: prevTop,
width: prevWidth,
height: prevHeight,
} = caculateRect(mat, width, height, n);
const posOrigin = caculatePosition(mat, origin, n);
const prevOrigin = minus(posOrigin, [prevLeft, prevTop]);
const rectOrigin = [
rectLeft + prevOrigin[0] * rectWidth / prevWidth,
rectTop + prevOrigin[1] * rectHeight / prevHeight,
];
const offset = [0, 0];
let count = 0;
while (++count < 10) {
const inverseBeforeMatrix = invert(beforeMatrix, n);
[offset[0], offset[1]] = minus(
caculatePosition(inverseBeforeMatrix, rectOrigin, n),
caculatePosition(inverseBeforeMatrix, posOrigin, n),
);
const mat2 = multiplies(
n,
beforeMatrix,
createOriginMatrix(offset, n),
absoluteMatrix,
);
const {
left: nextLeft,
top: nextTop,
} = caculateRect(mat2, width, height, n);
const distLeft = nextLeft - rectLeft;
const distTop = nextTop - rectTop;
(child, childDatas, eventParams) => {
const { left, top, beforeOrigin } = child.state;
const childClient = plus(
minus([left, top], [parentLeft, parentTop]),
minus(beforeOrigin, parentBeforeOrigin),
);
childDatas.prevClient = childClient;
eventParams.dragStart = Draggable.dragStart(
child,
new CustomDragger().dragStart(childClient, inputEvent),
);
},
);