Added priority in SnappingGuides

This commit is contained in:
Ramil Minyukov (Akvelon INC) 2021-09-06 19:56:42 +03:00
Родитель 7ba964fc43
Коммит ea67f2d4d7
3 изменённых файлов: 36 добавлений и 9 удалений

Просмотреть файл

@ -61,12 +61,18 @@ export class SnappingSession<ElementType> {
a: SnappableGuide<ElementType>,
b: SnappableGuide<ElementType>
) {
if (a.guide.type === "point" && b.guide.type !== "point") {
return -1;
} else if (a.guide.type === "point" && b.guide.type === "point") {
return 0;
const aPriority = a.guide?.priority ?? 0;
const bPriority = b.guide?.priority ?? 0;
if (aPriority > 0 || bPriority > 0) {
return bPriority - aPriority;
} else {
return 1;
if (a.guide.type === "point" && b.guide.type !== "point") {
return -1;
} else if (a.guide.type === "point" && b.guide.type === "point") {
return 0;
} else {
return 1;
}
}
}

Просмотреть файл

@ -278,6 +278,7 @@ export namespace SnappingGuides {
type: string;
visible: boolean;
visualType?: SnappingGuidesVisualTypes;
priority?: number;
}
export interface Axis extends Description {

Просмотреть файл

@ -241,10 +241,30 @@ export class CartesianPlotSegment extends PlotSegmentClass<
const attrs = this.state.attributes;
const { x1, y1, x2, y2 } = attrs;
return [
<SnappingGuides.Axis>{ type: "x", value: x1, attribute: "x1" },
<SnappingGuides.Axis>{ type: "x", value: x2, attribute: "x2" },
<SnappingGuides.Axis>{ type: "y", value: y1, attribute: "y1" },
<SnappingGuides.Axis>{ type: "y", value: y2, attribute: "y2" },
<SnappingGuides.Axis>{
type: "x",
value: x1,
attribute: "x1",
priority: 1,
},
<SnappingGuides.Axis>{
type: "x",
value: x2,
attribute: "x2",
priority: 1,
},
<SnappingGuides.Axis>{
type: "y",
value: y1,
attribute: "y1",
priority: 1,
},
<SnappingGuides.Axis>{
type: "y",
value: y2,
attribute: "y2",
priority: 1,
},
];
}