terra-draw
Advanced tools
Comparing version 0.0.1-alpha.69 to 0.0.1-alpha.70
import { Point, Position } from "geojson"; | ||
import { Project, Unproject } from "../common"; | ||
import { Project, Projection, Unproject } from "../common"; | ||
import { JSONObject } from "../store/store"; | ||
export declare function getMidPointCoordinates(featureCoords: Position[], precision: number, project: Project, unproject: Unproject): Position[]; | ||
export declare function getMidPoints(selectedCoords: Position[], properties: (index: number) => JSONObject, precision: number, project: Project, unproject: Unproject): { | ||
export declare function getMidPointCoordinates({ featureCoords, precision, unproject, project, projection, }: { | ||
featureCoords: Position[]; | ||
precision: number; | ||
project: Project; | ||
unproject: Unproject; | ||
projection: Projection; | ||
}): Position[]; | ||
export declare function getMidPoints(selectedCoords: Position[], properties: (index: number) => JSONObject, precision: number, project: Project, unproject: Unproject, projection: Projection): { | ||
geometry: Point; | ||
properties: JSONObject; | ||
}[]; |
import { Position } from "geojson"; | ||
export declare function bearing(start: Position, end: Position): number; | ||
export declare function webMercatorBearing({ x: x1, y: y1 }: { | ||
x: number; | ||
y: number; | ||
}, { x: x2, y: y2 }: { | ||
x: number; | ||
y: number; | ||
}): number; |
import { Position } from "geojson"; | ||
import { Project, Unproject } from "../common"; | ||
export declare function midpointCoordinate(coordinates1: Position, coordinates2: Position, precision: number, project: Project, unproject: Unproject): number[]; | ||
export declare function geodesicMidpointCoordinate(coordinates1: Position, coordinates2: Position, precision: number): number[]; |
import { Feature, LineString, Polygon } from "geojson"; | ||
export declare function transformRotate(geojson: Feature<Polygon | LineString>, angle: number): Feature<Polygon | LineString, import("geojson").GeoJsonProperties>; | ||
export declare function transformRotate(feature: Feature<Polygon | LineString>, angle: number): Feature<Polygon | LineString, import("geojson").GeoJsonProperties>; | ||
/** | ||
* Rotate a GeoJSON Polygon geometry in web mercator | ||
* @param polygon - GeoJSON Polygon geometry | ||
* @param angle - rotation angle in degrees | ||
* @returns - rotated GeoJSON Polygon geometry | ||
*/ | ||
export declare const transformRotateWebMercator: (feature: Feature<Polygon> | Feature<LineString>, angle: number) => Feature<Polygon, import("geojson").GeoJsonProperties> | Feature<LineString, import("geojson").GeoJsonProperties>; |
import { Feature, LineString, Polygon, Position } from "geojson"; | ||
export declare function transformScale(feature: Feature<Polygon | LineString>, factor: number, origin: Position, axis?: "x" | "y" | "xy"): Feature<Polygon | LineString, import("geojson").GeoJsonProperties>; | ||
/** | ||
* Scale a GeoJSON Polygon geometry in web mercator | ||
* @param polygon - GeoJSON Polygon geometry | ||
* @param scale - scaling factor | ||
* @returns - scaled GeoJSON Polygon geometry | ||
*/ | ||
export declare function transformScaleWebMercator(feature: Feature<Polygon | LineString>, factor: number, origin: Position): Feature<Polygon | LineString>; |
@@ -1,2 +0,2 @@ | ||
import { Project, Unproject } from "../common"; | ||
import { Project, Projection, Unproject } from "../common"; | ||
import { GeoJSONStore } from "../store/store"; | ||
@@ -10,2 +10,3 @@ export type BehaviorConfig = { | ||
coordinatePrecision: number; | ||
projection: Projection; | ||
}; | ||
@@ -19,3 +20,4 @@ export declare class TerraDrawModeBehavior { | ||
protected coordinatePrecision: number; | ||
constructor({ store, mode, project, unproject, pointerDistance, coordinatePrecision, }: BehaviorConfig); | ||
protected projection: Projection; | ||
constructor({ store, mode, project, unproject, pointerDistance, coordinatePrecision, projection, }: BehaviorConfig); | ||
} |
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior"; | ||
import { HexColor, OnFinishContext, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation } from "../common"; | ||
import { HexColor, OnFinishContext, Projection, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation } from "../common"; | ||
import { FeatureId, GeoJSONStore, GeoJSONStoreFeatures, StoreChangeHandler } from "../store/store"; | ||
@@ -15,2 +15,3 @@ export type CustomStyling = Record<string, string | number | ((feature: GeoJSONStoreFeatures) => HexColor) | ((feature: GeoJSONStoreFeatures) => number)>; | ||
validation?: Validation; | ||
projection?: Projection; | ||
}; | ||
@@ -35,2 +36,3 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> { | ||
protected registerBehaviors(behaviorConfig: BehaviorConfig): void; | ||
protected projection: Projection; | ||
constructor(options?: BaseModeOptions<T>); | ||
@@ -37,0 +39,0 @@ type: ModeTypes; |
@@ -25,3 +25,2 @@ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, Projection } from "../../common"; | ||
mode: string; | ||
private projection; | ||
private center; | ||
@@ -28,0 +27,0 @@ private clickCount; |
@@ -1,2 +0,2 @@ | ||
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, Projection } from "../../common"; | ||
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common"; | ||
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode"; | ||
@@ -31,7 +31,5 @@ import { BehaviorConfig } from "../base.behavior"; | ||
insertCoordinates?: InertCoordinates; | ||
projection?: Projection; | ||
} | ||
export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineStringStyling> { | ||
mode: string; | ||
private projection; | ||
private currentCoordinate; | ||
@@ -38,0 +36,0 @@ private currentId; |
@@ -7,3 +7,3 @@ import { TerraDrawMouseEvent, Validation } from "../../../common"; | ||
import { FeatureId } from "../../../store/store"; | ||
export type ResizeOptions = "center-web-mercator" | "opposite-web-mercator" | "center-fixed-web-mercator" | "opposite-fixed-web-mercator"; | ||
export type ResizeOptions = "center" | "opposite" | "center-fixed" | "opposite-fixed"; | ||
export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior { | ||
@@ -59,3 +59,3 @@ readonly config: BehaviorConfig; | ||
* @param event - cursor event | ||
* @param resizeOption - the resize option, either "center-web-mercator" or "opposite-web-mercator" | ||
* @param resizeOption - the resize option, either "center" or "opposite" | ||
* @returns - true is resize was successful, false otherwise | ||
@@ -62,0 +62,0 @@ */ |
@@ -60,3 +60,3 @@ import { TerraDrawGoogleMapsAdapter } from "./adapters/google-maps.adapter"; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -69,3 +69,3 @@ setModeStyles<Styling extends Record<string, number | HexColor>>(mode: string, styles: Styling): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -77,3 +77,3 @@ getSnapshot(): GeoJSONStoreFeatures[]; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -88,3 +88,3 @@ clear(): void; | ||
* @readonly | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -95,3 +95,3 @@ get enabled(): boolean; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -104,3 +104,3 @@ set enabled(_: boolean); | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -113,3 +113,3 @@ getMode(): string; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -122,3 +122,3 @@ setMode(mode: string): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -131,3 +131,3 @@ removeFeatures(ids: FeatureId[]): void; | ||
* @param id - the id of the feature to select | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -140,3 +140,3 @@ selectFeature(id: FeatureId): void; | ||
* @param id - the id of the feature to deselect | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -150,3 +150,3 @@ deselectFeature(id: FeatureId): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -158,3 +158,3 @@ getFeatureId(): FeatureId; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -169,3 +169,3 @@ hasFeature(id: FeatureId): boolean; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -177,3 +177,3 @@ addFeatures(features: GeoJSONStoreFeatures[]): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -186,3 +186,3 @@ start(): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -201,3 +201,3 @@ getFeaturesAtLngLat(lngLat: { | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -212,3 +212,3 @@ getFeaturesAtPointerEvent(event: PointerEvent | MouseEvent, options?: { | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -222,3 +222,3 @@ stop(): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -232,3 +232,3 @@ on<T extends TerraDrawEvents>(event: T, callback: TerraDrawEventListeners[T]): void; | ||
* | ||
* @alpha | ||
* @beta | ||
*/ | ||
@@ -235,0 +235,0 @@ off<T extends TerraDrawEvents>(event: TerraDrawEvents, callback: TerraDrawEventListeners[T]): void; |
@@ -85,9 +85,9 @@ import { test, expect } from "@playwright/test"; | ||
name: " with insert coordinates for web mercator projection", | ||
config: "insertCoordinates", | ||
config: ["insertCoordinates"], | ||
}, | ||
{ | ||
name: " with insert coordinates for globe projection", | ||
config: "insertCoordinatesGlobe", | ||
config: ["insertCoordinatesGlobe"], | ||
}, | ||
] as { name: string; config: TestConfigOptions }[]; | ||
] as { name: string; config: TestConfigOptions[] }[]; | ||
@@ -239,3 +239,3 @@ for (const { name, config } of options) { | ||
page, | ||
configQueryParam: "validationFailure", | ||
configQueryParam: ["validationFailure"], | ||
}); | ||
@@ -279,3 +279,3 @@ await changeMode({ page, mode }); | ||
page, | ||
configQueryParam: "validationSuccess", | ||
configQueryParam: ["validationSuccess"], | ||
}); | ||
@@ -355,3 +355,3 @@ await changeMode({ page, mode }); | ||
}) => { | ||
const mapDiv = await setupMap({ page, configQueryParam: "geodesicCircle" }); | ||
const mapDiv = await setupMap({ page, configQueryParam: ["globeCircle"] }); | ||
await changeMode({ page, mode }); | ||
@@ -372,188 +372,202 @@ | ||
test("mode can set and then polygon can be selected and deselected", async ({ | ||
page, | ||
}) => { | ||
const mapDiv = await setupMap({ page }); | ||
const options = [ | ||
{ name: "in web mercator projection", config: undefined }, | ||
{ | ||
name: "in globe projection", | ||
config: ["globeSelect"], | ||
}, | ||
] as { name: string; config: TestConfigOptions[] }[]; | ||
await changeMode({ page, mode: "polygon" }); | ||
const sideLength = 100; | ||
const halfLength = sideLength / 2; | ||
const centerX = mapDiv.width / 2; | ||
const centerY = mapDiv.height / 2; | ||
const topLeft = { x: centerX - halfLength, y: centerY - halfLength }; | ||
const topRight = { x: centerX + halfLength, y: centerY - halfLength }; | ||
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength }; | ||
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength }; | ||
await page.mouse.click(topLeft.x, topLeft.y); | ||
await page.mouse.click(topRight.x, topRight.y); | ||
await page.mouse.click(bottomRight.x, bottomRight.y); | ||
await page.mouse.click(bottomLeft.x, bottomLeft.y); | ||
await page.mouse.click(bottomLeft.x, bottomLeft.y); // Closed | ||
for (const { name, config } of options) { | ||
test(`mode can set and then polygon can be selected and deselected ${name}`, async ({ | ||
page, | ||
}) => { | ||
const mapDiv = await setupMap({ page, configQueryParam: config }); | ||
await changeMode({ page, mode }); | ||
await changeMode({ page, mode: "polygon" }); | ||
const sideLength = 100; | ||
const halfLength = sideLength / 2; | ||
const centerX = mapDiv.width / 2; | ||
const centerY = mapDiv.height / 2; | ||
const topLeft = { x: centerX - halfLength, y: centerY - halfLength }; | ||
const topRight = { x: centerX + halfLength, y: centerY - halfLength }; | ||
const bottomLeft = { x: centerX - halfLength, y: centerY + halfLength }; | ||
const bottomRight = { x: centerX + halfLength, y: centerY + halfLength }; | ||
await page.mouse.click(topLeft.x, topLeft.y); | ||
await page.mouse.click(topRight.x, topRight.y); | ||
await page.mouse.click(bottomRight.x, bottomRight.y); | ||
await page.mouse.click(bottomLeft.x, bottomLeft.y); | ||
await page.mouse.click(bottomLeft.x, bottomLeft.y); // Closed | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
await changeMode({ page, mode }); | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
await expectPaths({ page, count: 1 }); // 0 selection points and 1 square | ||
}); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
test("selected polygon can be dragged", async ({ page }) => { | ||
const mapDiv = await setupMap({ page }); | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
await expectPaths({ page, count: 1 }); // 0 selection points and 1 square | ||
}); | ||
await changeMode({ page, mode: "polygon" }); | ||
test(`selected polygon can be dragged ${name}`, async ({ page }) => { | ||
const mapDiv = await setupMap({ page, configQueryParam: config }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ mapDiv, page }); | ||
await changeMode({ page, mode: "polygon" }); | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ mapDiv, page }); | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Drag | ||
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2); | ||
await page.mouse.down(); | ||
await page.mouse.move(mapDiv.width / 2 + 50, mapDiv.height / 2 + 50, { | ||
steps: 30, | ||
}); // Steps is required | ||
await page.mouse.up(); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
// Drag | ||
await page.mouse.move(mapDiv.width / 2, mapDiv.height / 2); | ||
await page.mouse.down(); | ||
await page.mouse.move(mapDiv.width / 2 + 50, mapDiv.height / 2 + 50, { | ||
steps: 30, | ||
}); // Steps is required | ||
await page.mouse.up(); | ||
await expectGroupPosition({ page, x: x + 48, y: y + 48 }); | ||
}); | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
test("selected polygon can have individual coordinates dragged", async ({ | ||
page, | ||
}) => { | ||
const mapDiv = await setupMap({ page }); | ||
await expectGroupPosition({ page, x: x + 48, y: y + 48 }); | ||
}); | ||
await changeMode({ page, mode: "polygon" }); | ||
test(`selected polygon can have individual coordinates dragged ${name}`, async ({ | ||
page, | ||
}) => { | ||
const mapDiv = await setupMap({ page, configQueryParam: config }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ mapDiv, page }); | ||
await changeMode({ page, mode: "polygon" }); | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ mapDiv, page }); | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Drag | ||
await page.mouse.move(topLeft.x, topLeft.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(topLeft.x - 50, topLeft.y + 50, { steps: 30 }); // Steps is required | ||
await page.mouse.up(); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
// Drag | ||
await page.mouse.move(topLeft.x, topLeft.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(topLeft.x - 50, topLeft.y + 50, { steps: 30 }); // Steps is required | ||
await page.mouse.up(); | ||
// Dragged the coordinate to the left and down slightly | ||
await expectGroupPosition({ page, x: 538, y: 308 }); | ||
}); | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
test("selected polygon can have individual coordinates dragged and fail when validation fails", async ({ | ||
page, | ||
}) => { | ||
const mapDiv = await setupMap({ | ||
page, | ||
configQueryParam: "validationFailure", | ||
// Dragged the coordinate to the left and down slightly | ||
await expectGroupPosition({ page, x: 538, y: 308 }); | ||
}); | ||
await changeMode({ page, mode: "polygon" }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ | ||
mapDiv, | ||
test(`selected polygon can have individual coordinates dragged and succeeds when validation succeeds ${name}`, async ({ | ||
page, | ||
size: "small", | ||
}); | ||
}) => { | ||
const mapDiv = await setupMap({ | ||
page, | ||
configQueryParam: config | ||
? [...config, "validationSuccess"] | ||
: ["validationSuccess"], | ||
}); | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
await changeMode({ page, mode: "polygon" }); | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ | ||
mapDiv, | ||
page, | ||
size: "small", | ||
}); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
// await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
// Drag | ||
await page.mouse.move(topLeft.x, topLeft.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(0, 0, { steps: 30 }); | ||
await page.mouse.up(); | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
// await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// We are attempting to dragg right tothe top left corner but it is not getting there | ||
// because it is capped by the validation. If this was allowed x would be ~90 | ||
await expectGroupPosition({ page, x: 563, y: 301 }); | ||
}); | ||
// Drag | ||
await page.mouse.move(topLeft.x, topLeft.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(topLeft.x - 50, topLeft.y - 50, { steps: 30 }); | ||
await page.mouse.up(); | ||
test("selected polygon can have individual coordinates dragged and succeeds when validation succeeds", async ({ | ||
page, | ||
}) => { | ||
const mapDiv = await setupMap({ | ||
page, | ||
configQueryParam: "validationSuccess", | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
// We are attempting to dragg right tothe top left corner but it is not getting there | ||
// because it is capped by the validation. If this was allowed x would be ~90 | ||
await expectGroupPosition({ page, x: 553, y: 273 }); | ||
}); | ||
await changeMode({ page, mode: "polygon" }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ | ||
mapDiv, | ||
test(`selected polygon can have individual coordinates dragged and fail when validation fails ${name}`, async ({ | ||
page, | ||
size: "small", | ||
}); | ||
}) => { | ||
const mapDiv = await setupMap({ | ||
page, | ||
configQueryParam: config | ||
? [...config, "validationFailure"] | ||
: ["validationFailure"], | ||
}); | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
await changeMode({ page, mode: "polygon" }); | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Draw a rectangle | ||
const { topLeft } = await drawRectangularPolygon({ | ||
mapDiv, | ||
page, | ||
size: "small", | ||
}); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
// await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// Change to select mode | ||
await changeMode({ page, mode }); | ||
// Drag | ||
await page.mouse.move(topLeft.x, topLeft.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(topLeft.x - 50, topLeft.y - 50, { steps: 30 }); | ||
await page.mouse.up(); | ||
// Before drag | ||
const x = topLeft.x - 2; | ||
const y = topLeft.y - 2; | ||
await expectGroupPosition({ page, x, y }); | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
// Select | ||
await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2); | ||
// await expectPaths({ page, count: 9 }); // 8 selection points and 1 square | ||
// We are attempting to dragg right tothe top left corner but it is not getting there | ||
// because it is capped by the validation. If this was allowed x would be ~90 | ||
await expectGroupPosition({ page, x: 553, y: 273 }); | ||
}); | ||
// Drag | ||
await page.mouse.move(topLeft.x, topLeft.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(0, 0, { steps: 30 }); | ||
await page.mouse.up(); | ||
test("selected rectangle has it's shape maintained when coordinates are dragged with resizeable flag", async ({ | ||
// Deselect | ||
await page.mouse.click(mapDiv.width - 10, mapDiv.height / 2); | ||
// We are attempting to dragg right tothe top left corner but it is not getting there | ||
// because it is capped by the validation. If this was allowed x would be ~90 | ||
await expectGroupPosition({ page, x: 563, y: 301 }); | ||
}); | ||
} | ||
test("selected rectangle has it's shape maintained when coordinates are dragged with resizable flag", async ({ | ||
page, | ||
@@ -593,3 +607,3 @@ }) => { | ||
test("selected circle can has it's shape maintained from center origin when coordinates are dragged", async ({ | ||
test("selected circle has it's shape maintained from center origin when coordinates are dragged with resizable flag", async ({ | ||
page, | ||
@@ -596,0 +610,0 @@ }) => { |
@@ -10,3 +10,4 @@ import { Page, expect } from "@playwright/test"; | ||
| "insertCoordinatesGlobe" | ||
| "geodesicCircle"; | ||
| "globeCircle" | ||
| "globeSelect"; | ||
@@ -18,3 +19,3 @@ export const setupMap = async ({ | ||
page: Page; | ||
configQueryParam?: TestConfigOptions; | ||
configQueryParam?: TestConfigOptions[]; | ||
}): Promise<{ | ||
@@ -27,3 +28,11 @@ x: number; | ||
if (configQueryParam) { | ||
await page.goto(pageUrl + "?config=" + configQueryParam); | ||
if (configQueryParam.length > 1) { | ||
await page.goto( | ||
pageUrl + | ||
"?config=" + | ||
configQueryParam.map((config) => config).join(","), | ||
); | ||
} else { | ||
await page.goto(pageUrl + "?config=" + configQueryParam); | ||
} | ||
} else { | ||
@@ -30,0 +39,0 @@ await page.goto(pageUrl); |
{ | ||
"name": "terra-draw", | ||
"version": "0.0.1-alpha.69", | ||
"version": "0.0.1-alpha.70", | ||
"description": "Frictionless map drawing across mapping provider", | ||
@@ -9,4 +9,4 @@ "scripts": { | ||
"release": "standard-version", | ||
"release:alpha:changelog": "tsx ./scripts/changelog-valid.ts", | ||
"release:alpha:next": "tsx ./scripts/next-alpha-version.ts", | ||
"release:beta:changelog": "tsx ./scripts/changelog-valid.ts", | ||
"release:beta:next": "tsx ./scripts/next-beta-version.ts", | ||
"build": "microbundle", | ||
@@ -13,0 +13,0 @@ "watch": "microbundle --watch --format modern", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4309202
9433