mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
fix formatting
This commit is contained in:
parent
6ed8e39437
commit
c304c3c0cf
2 changed files with 16 additions and 12 deletions
13
dist/workers/graph.js
vendored
13
dist/workers/graph.js
vendored
|
@ -586,6 +586,7 @@ drawNode = (d) => {
|
|||
drawDragToSelectBox = () => {
|
||||
const width = dragToSelectCursorCoord.x - dragToSelectStartCoord.x;
|
||||
const height = dragToSelectCursorCoord.y - dragToSelectStartCoord.y;
|
||||
|
||||
util.roundedRect(dragToSelectStartCoord.x, dragToSelectStartCoord.y, width, height, 1);
|
||||
|
||||
ctx.strokeStyle = data.colors.selected;
|
||||
|
@ -601,19 +602,19 @@ onZoom = (data) => {
|
|||
};
|
||||
|
||||
onDragToSelectStart = (data) => {
|
||||
let {x, y} = data;
|
||||
let { x, y } = data;
|
||||
|
||||
x = transform.invertX(x);
|
||||
y = transform.invertY(y);
|
||||
dragToSelectStartCoord = {x: x, y: y};
|
||||
dragToSelectStartCoord = { x: x, y: y };
|
||||
}
|
||||
|
||||
onDragToSelectMove = (data) => {
|
||||
let {x, y} = data;
|
||||
let { x, y } = data;
|
||||
|
||||
x = transform.invertX(x);
|
||||
y = transform.invertY(y);
|
||||
dragToSelectCursorCoord = {x: x, y: y};
|
||||
dragToSelectCursorCoord = { x: x, y: y };
|
||||
|
||||
const left = Math.min(dragToSelectStartCoord.x, x);
|
||||
const top = Math.min(dragToSelectStartCoord.y, y);
|
||||
|
@ -621,8 +622,8 @@ onDragToSelectMove = (data) => {
|
|||
const bottom = Math.max(dragToSelectStartCoord.y, y);
|
||||
|
||||
const selected = [];
|
||||
nodes.forEach((d) => {
|
||||
if (d.x >= left && d.x <= right && d.y >= top && d.y <= bottom) {
|
||||
nodes.forEach(d => {
|
||||
if (d.x >= left) && (d.x <= right) && (d.y >= top) && (d.y <= bottom) {
|
||||
selected.push(d.id);
|
||||
};
|
||||
});
|
||||
|
|
|
@ -233,17 +233,18 @@ const Graph = observer(forwardRef<GraphRefProps, Props>(({
|
|||
};
|
||||
|
||||
const onZoomStart = ({ sourceEvent }) => {
|
||||
if (sourceEvent && sourceEvent.type === 'mousedown' && sourceEvent.shiftKey) {
|
||||
if (sourceEvent && (sourceEvent.type == 'mousedown') && sourceEvent.shiftKey) {
|
||||
const p = d3.pointer(sourceEvent, d3.select(canvas.current));
|
||||
const node = $(nodeRef.current);
|
||||
const { left, top } = node.offset();
|
||||
|
||||
isDraggingToSelect.current = true;
|
||||
send('onDragToSelectStart', { x: p[0] - left, y: p[1] - top });
|
||||
};
|
||||
};
|
||||
|
||||
const onZoom = ({ transform, sourceEvent }) => {
|
||||
if(isDraggingToSelect.current && sourceEvent) {
|
||||
if (isDraggingToSelect.current && sourceEvent) {
|
||||
const p = d3.pointer(sourceEvent, d3.select(canvas.current));
|
||||
const node = $(nodeRef.current);
|
||||
const { left, top } = node.offset();
|
||||
|
@ -255,10 +256,11 @@ const Graph = observer(forwardRef<GraphRefProps, Props>(({
|
|||
};
|
||||
|
||||
const onZoomEnd = (e: any) => {
|
||||
if(isDraggingToSelect.current){
|
||||
if (isDraggingToSelect.current){
|
||||
send('onDragToSelectEnd', {});
|
||||
nodesSelectedByDragToSelect.current = [];
|
||||
};
|
||||
|
||||
isDraggingToSelect.current = false;
|
||||
};
|
||||
|
||||
|
@ -384,18 +386,19 @@ const Graph = observer(forwardRef<GraphRefProps, Props>(({
|
|||
const currentSelected = data.selected;
|
||||
|
||||
setSelected(ids.current.filter((id: string) => {
|
||||
if(!nodesSelectedByDragToSelect.current.includes(id)){
|
||||
if (!nodesSelectedByDragToSelect.current.includes(id)){
|
||||
return true;
|
||||
}
|
||||
return currentSelected.includes(id);
|
||||
}));
|
||||
|
||||
nodesSelectedByDragToSelect.current = nodesSelectedByDragToSelect.current.filter(id => currentSelected.includes(id));
|
||||
|
||||
|
||||
currentSelected.forEach((id: string) => {
|
||||
if(ids.current.includes(id)){
|
||||
if (ids.current.includes(id)){
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
setSelected(ids.current.concat([id]));
|
||||
nodesSelectedByDragToSelect.current = nodesSelectedByDragToSelect.current.concat([id]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue