Added priority in SnappingGuides
This commit is contained in:
Родитель
7ba964fc43
Коммит
ea67f2d4d7
|
@ -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,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче