@evergis/sgis
Advanced tools
Comparing version 0.5.0-alpha.23 to 0.5.0-alpha.24
@@ -149,3 +149,4 @@ import { EventHandler, sGisEvent } from "../EventHandler"; | ||
*/ | ||
protected _snap(point: Coordinates, isAltPressed: boolean, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean, snappingProviderOverride?: ISnappingProvider): Coordinates; | ||
protected _snap(point: Coordinates, isAltPressed: boolean, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean, snappingProviderOverride?: ISnappingProvider): Promise<Coordinates> | Coordinates; | ||
protected _snappingPointRender(currentPosition: Coordinates, snappingPointResult: Coordinates): void; | ||
/** | ||
@@ -155,3 +156,3 @@ * Removes snapping point from the temp layer. | ||
protected _unsnap(): void; | ||
private _getSnappingFeature; | ||
protected _getSnappingFeature(point: Coordinates | null): PointFeature; | ||
/** | ||
@@ -158,0 +159,0 @@ * Map the control works with. |
@@ -19,3 +19,3 @@ import { Control, ControlWithSymbolParams } from "./Control"; | ||
*/ | ||
constructor(map: Map, { activeLayer, snappingProvider, isActive, symbol }?: ControlWithSymbolParams); | ||
constructor(map: Map, { activeLayer, snappingProvider, snappingSymbol, isActive, symbol }?: ControlWithSymbolParams); | ||
protected _activate(): void; | ||
@@ -25,2 +25,4 @@ protected _deactivate(): void; | ||
protected _handleMouseMove(event: sGisEvent): void; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Control, ControlParams } from "./Control"; | ||
import { Control, ControlParams } from './Control'; | ||
import { PointFeature } from "../features/PointFeature"; | ||
@@ -16,3 +16,3 @@ import { Map } from "../Map"; | ||
*/ | ||
constructor(map: Map, { snappingProvider, isActive, activeLayer }?: ControlParams); | ||
constructor(map: Map, { snappingProvider, snappingSymbol, isActive, activeLayer }?: ControlParams); | ||
protected _activate(): void; | ||
@@ -27,3 +27,5 @@ protected _deactivate(): void; | ||
private _handleDrag; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
private _handleDragEnd; | ||
} |
@@ -34,3 +34,3 @@ import { Control, ControlWithSymbolParams } from "./Control"; | ||
*/ | ||
protected constructor(map: Map, { snappingProvider, activeLayer, isActive, symbol, dblClickMinTime }?: PolyControlParams); | ||
protected constructor(map: Map, { snappingProvider, snappingSymbol, activeLayer, isActive, symbol, dblClickMinTime }?: PolyControlParams); | ||
protected _activate(): void; | ||
@@ -46,2 +46,4 @@ protected _deactivate(): void; | ||
protected _handleMousemove(event: sGisEvent): void; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
private _handleDblclick; | ||
@@ -48,0 +50,0 @@ /** |
@@ -49,2 +49,4 @@ import { Control, ControlParams } from "./Control"; | ||
private _handleDrag; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
get isDraggingVertex(): boolean; | ||
@@ -51,0 +53,0 @@ private _handleDragEnd; |
@@ -17,3 +17,3 @@ import { Contour, Coordinates } from "../../baseTypes"; | ||
*/ | ||
getSnappingPoint(point: Coordinates, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean): Coordinates | null; | ||
getSnappingPoint(point: Coordinates, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean): Promise<Coordinates | null> | Coordinates | null; | ||
/** | ||
@@ -20,0 +20,0 @@ * Returns a copy of the given provider. This method is needed to create complex snapping providers, consisting |
@@ -18,5 +18,2 @@ import { HTMLRasterElement, Offset } from "../baseTypes"; | ||
private _src; | ||
private _controller; | ||
private _complete; | ||
private _aborted; | ||
offset: Offset; | ||
@@ -35,4 +32,2 @@ onLoad?: () => void; | ||
set opacity(value: number); | ||
get isImageLoaded(): boolean; | ||
deleteNode(): void; | ||
} |
@@ -63,4 +63,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export declare const version = "0.5.0-alpha.23"; | ||
export declare const releaseDate = "12.07.2022"; | ||
export declare const version = "0.5.0-alpha.24"; | ||
export declare const releaseDate = "27.07.2022"; | ||
export declare const controls: { | ||
@@ -67,0 +67,0 @@ Circle: typeof Circle; |
@@ -92,2 +92,2 @@ /** | ||
*/ | ||
export declare function loadImage(image: HTMLImageElement, src: string, signal: AbortSignal | null): Promise<void>; | ||
export declare function loadImage(image: HTMLImageElement, src: string): Promise<void>; |
@@ -149,3 +149,4 @@ import { EventHandler, sGisEvent } from "../EventHandler"; | ||
*/ | ||
protected _snap(point: Coordinates, isAltPressed: boolean, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean, snappingProviderOverride?: ISnappingProvider): Coordinates; | ||
protected _snap(point: Coordinates, isAltPressed: boolean, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean, snappingProviderOverride?: ISnappingProvider): Promise<Coordinates> | Coordinates; | ||
protected _snappingPointRender(currentPosition: Coordinates, snappingPointResult: Coordinates): void; | ||
/** | ||
@@ -155,3 +156,3 @@ * Removes snapping point from the temp layer. | ||
protected _unsnap(): void; | ||
private _getSnappingFeature; | ||
protected _getSnappingFeature(point: Coordinates | null): PointFeature; | ||
/** | ||
@@ -158,0 +159,0 @@ * Map the control works with. |
@@ -139,8 +139,14 @@ import { EventHandler, sGisEvent } from "../EventHandler"; | ||
} | ||
Promise.resolve(snappingPoint).then((snappingPointResult) => { | ||
this._snappingPointRender(point, snappingPointResult); | ||
}); | ||
return snappingPoint || point; | ||
} | ||
_snappingPointRender(currentPosition, snappingPointResult) { | ||
if (this._tempLayer) { | ||
const snappingFeature = this._getSnappingFeature(snappingPoint || point); | ||
if (snappingPoint && !this._tempLayer.has(snappingFeature)) { | ||
const snappingFeature = this._getSnappingFeature(snappingPointResult || currentPosition); | ||
if (snappingPointResult && !this._tempLayer.has(snappingFeature)) { | ||
this._tempLayer.add(snappingFeature); | ||
} | ||
else if (!snappingPoint && this._tempLayer.has(snappingFeature)) { | ||
else if (!snappingPointResult && this._tempLayer.has(snappingFeature)) { | ||
this._tempLayer.remove(snappingFeature); | ||
@@ -150,3 +156,2 @@ } | ||
} | ||
return snappingPoint || point; | ||
} | ||
@@ -153,0 +158,0 @@ /** |
@@ -19,3 +19,3 @@ import { Control, ControlWithSymbolParams } from "./Control"; | ||
*/ | ||
constructor(map: Map, { activeLayer, snappingProvider, isActive, symbol }?: ControlWithSymbolParams); | ||
constructor(map: Map, { activeLayer, snappingProvider, snappingSymbol, isActive, symbol }?: ControlWithSymbolParams); | ||
protected _activate(): void; | ||
@@ -25,2 +25,4 @@ protected _deactivate(): void; | ||
protected _handleMouseMove(event: sGisEvent): void; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
} |
@@ -0,5 +1,6 @@ | ||
import { debounce } from '../utils/utils'; | ||
import { Control, DrawingFinishEvent } from "./Control"; | ||
import { PointFeature } from "../features/PointFeature"; | ||
import { PointSymbol } from "../symbols/point/Point"; | ||
import { sGisClickEvent, sGisMouseMoveEvent } from "../commonEvents"; | ||
import { sGisClickEvent, sGisMouseMoveEvent } from '../commonEvents'; | ||
/** | ||
@@ -16,4 +17,5 @@ * Control for creating point features. When active, any click on the map will create a new point feature and add it | ||
*/ | ||
constructor(map, { activeLayer, snappingProvider, isActive = false, symbol = new PointSymbol() } = {}) { | ||
super(map, { activeLayer, snappingProvider, useTempLayer: true }); | ||
constructor(map, { activeLayer, snappingProvider, snappingSymbol, isActive = false, symbol = new PointSymbol() } = {}) { | ||
super(map, { activeLayer, snappingProvider, snappingSymbol, useTempLayer: true }); | ||
this._debouncedSnappingHandle = debounce(this._snappingHandle.bind(this), 50); | ||
this._handleClick = this._handleClick.bind(this); | ||
@@ -35,11 +37,18 @@ this._handleMouseMove = this._handleMouseMove.bind(this); | ||
let clickEvent = event; | ||
let feature = new PointFeature(this._snap(clickEvent.point.position, clickEvent.browserEvent.altKey), { crs: this.map.crs, symbol: this.symbol }); | ||
if (this.activeLayer) | ||
this.activeLayer.add(feature); | ||
this.fire(new DrawingFinishEvent(feature, clickEvent.browserEvent)); | ||
const snappingResult = this._snap(clickEvent.point.position, clickEvent.browserEvent.altKey); | ||
Promise.resolve(snappingResult).then((point) => { | ||
let feature = new PointFeature(point || clickEvent.point.position, { crs: this.map.crs, symbol: this.symbol }); | ||
if (this.activeLayer) | ||
this.activeLayer.add(feature); | ||
this.fire(new DrawingFinishEvent(feature, clickEvent.browserEvent)); | ||
}); | ||
} | ||
_handleMouseMove(event) { | ||
let mouseMoveEvent = event; | ||
this._snap(mouseMoveEvent.point.position, mouseMoveEvent.browserEvent.altKey); | ||
this._unsnap(); | ||
this._debouncedSnappingHandle(mouseMoveEvent); | ||
} | ||
_snappingHandle(event) { | ||
this._snap(event.point.position, event.browserEvent.altKey); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Control, ControlParams } from "./Control"; | ||
import { Control, ControlParams } from './Control'; | ||
import { PointFeature } from "../features/PointFeature"; | ||
@@ -16,3 +16,3 @@ import { Map } from "../Map"; | ||
*/ | ||
constructor(map: Map, { snappingProvider, isActive, activeLayer }?: ControlParams); | ||
constructor(map: Map, { snappingProvider, snappingSymbol, isActive, activeLayer }?: ControlParams); | ||
protected _activate(): void; | ||
@@ -27,3 +27,5 @@ protected _deactivate(): void; | ||
private _handleDrag; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
private _handleDragEnd; | ||
} |
@@ -1,2 +0,3 @@ | ||
import { Control, EditEvent } from "./Control"; | ||
import { debounce } from '../utils/utils'; | ||
import { Control, EditEvent } from './Control'; | ||
import { DragEndEvent, DragEvent, DragStartEvent } from "../commonEvents"; | ||
@@ -13,6 +14,7 @@ /** | ||
*/ | ||
constructor(map, { snappingProvider, isActive = false, activeLayer } = {}) { | ||
super(map, { useTempLayer: true, snappingProvider, activeLayer }); | ||
constructor(map, { snappingProvider, snappingSymbol, isActive = false, activeLayer } = {}) { | ||
super(map, { useTempLayer: true, snappingProvider, snappingSymbol, activeLayer }); | ||
this._activeFeature = null; | ||
this.ignoreEvents = false; | ||
this._debouncedSnappingHandle = debounce(this._snappingHandle.bind(this), 50); | ||
this._handleDragStart = this._handleDragStart.bind(this); | ||
@@ -58,6 +60,16 @@ this._handleDrag = this._handleDrag.bind(this); | ||
let dragEvent = event; | ||
this._activeFeature.position = this._snap(dragEvent.point.position, dragEvent.browserEvent.altKey); | ||
this._activeFeature.position = dragEvent.point.position; | ||
if (this.activeLayer) | ||
this.activeLayer.redraw(); | ||
this._unsnap(); | ||
this._debouncedSnappingHandle(dragEvent); | ||
} | ||
_snappingHandle(event) { | ||
const snappingResult = this._snap(event.point.position, event.browserEvent.altKey); | ||
Promise.resolve(snappingResult).then((point) => { | ||
this._activeFeature.position = point || event.point.position; | ||
if (this.activeLayer) | ||
this.activeLayer.redraw(); | ||
}); | ||
} | ||
_handleDragEnd() { | ||
@@ -64,0 +76,0 @@ this.fire(new EditEvent()); |
@@ -34,3 +34,3 @@ import { Control, ControlWithSymbolParams } from "./Control"; | ||
*/ | ||
protected constructor(map: Map, { snappingProvider, activeLayer, isActive, symbol, dblClickMinTime }?: PolyControlParams); | ||
protected constructor(map: Map, { snappingProvider, snappingSymbol, activeLayer, isActive, symbol, dblClickMinTime }?: PolyControlParams); | ||
protected _activate(): void; | ||
@@ -46,2 +46,4 @@ protected _deactivate(): void; | ||
protected _handleMousemove(event: sGisEvent): void; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
private _handleDblclick; | ||
@@ -48,0 +50,0 @@ /** |
@@ -0,3 +1,4 @@ | ||
import { debounce } from '../utils/utils'; | ||
import { ChangeEvent, Control, DrawingBeginEvent, DrawingFinishEvent, PointAddEvent } from "./Control"; | ||
import { sGisClickEvent, sGisDoubleClickEvent, sGisMouseMoveEvent } from "../commonEvents"; | ||
import { sGisClickEvent, sGisDoubleClickEvent, sGisMouseMoveEvent } from '../commonEvents'; | ||
/** | ||
@@ -19,6 +20,7 @@ * Base class for polyline and polygon controls. When active, click on the map will start a new feature, then | ||
*/ | ||
constructor(map, { snappingProvider, activeLayer, isActive = false, symbol, dblClickMinTime = 30 } = {}) { | ||
super(map, { snappingProvider, activeLayer, useTempLayer: true }); | ||
constructor(map, { snappingProvider, snappingSymbol, activeLayer, isActive = false, symbol, dblClickMinTime = 30 } = {}) { | ||
super(map, { snappingProvider, snappingSymbol, activeLayer, useTempLayer: true }); | ||
this._dblClickTime = 0; | ||
this._activeFeature = null; | ||
this._debouncedSnappingHandle = debounce(this._snappingHandle.bind(this), 50); | ||
this._handleClick = this._handleClick.bind(this); | ||
@@ -52,3 +54,10 @@ this._handleMousemove = this._handleMousemove.bind(this); | ||
else { | ||
this._activeFeature.addPoint(this._snap(clickEvent.point.position, clickEvent.browserEvent.altKey), this._activeFeature.rings.length - 1); | ||
const snappingResult = this._snap(clickEvent.point.position, clickEvent.browserEvent.altKey); | ||
Promise.resolve(snappingResult).then((point) => { | ||
this._activeFeature.addPoint(point, this._activeFeature.rings.length - 1); | ||
this.fire(new PointAddEvent()); | ||
if (this._tempLayer) | ||
this._tempLayer.redraw(); | ||
}); | ||
return; | ||
} | ||
@@ -79,3 +88,2 @@ } | ||
let mousemoveEvent = event; | ||
let position = this._snap(mousemoveEvent.point.position, mousemoveEvent.browserEvent.altKey); | ||
if (!this._activeFeature) | ||
@@ -85,8 +93,22 @@ return; | ||
let pointIndex = this._activeFeature.rings[ringIndex].length - 1; | ||
this._activeFeature.rings[ringIndex][pointIndex] = this._snap(position, mousemoveEvent.browserEvent.altKey, this._activeFeature.rings[ringIndex], pointIndex, this._activeFeature.isEnclosed); | ||
this._activeFeature.rings[ringIndex][pointIndex] = mousemoveEvent.point.position; | ||
this._activeFeature.redraw(); | ||
if (this._tempLayer) | ||
this._tempLayer.redraw(); | ||
this._unsnap(); | ||
this.fire(new ChangeEvent(ringIndex, pointIndex)); | ||
this._debouncedSnappingHandle(mousemoveEvent); | ||
} | ||
_snappingHandle(event) { | ||
let ringIndex = this._activeFeature.rings.length - 1; | ||
let pointIndex = this._activeFeature.rings[ringIndex].length - 1; | ||
const snappingResult = this._snap(event.point.position, event.browserEvent.altKey, this._activeFeature.rings[ringIndex], pointIndex, this._activeFeature.isEnclosed); | ||
Promise.resolve(snappingResult).then((point) => { | ||
this._activeFeature.rings[ringIndex][pointIndex] = point || event.point.position; | ||
this._activeFeature.redraw(); | ||
if (this._tempLayer) | ||
this._tempLayer.redraw(); | ||
this.fire(new ChangeEvent(ringIndex, pointIndex)); | ||
}); | ||
} | ||
_handleDblclick(event) { | ||
@@ -93,0 +115,0 @@ let feature = this._activeFeature; |
@@ -49,2 +49,4 @@ import { Control, ControlParams } from "./Control"; | ||
private _handleDrag; | ||
private _snappingHandle; | ||
private _debouncedSnappingHandle; | ||
get isDraggingVertex(): boolean; | ||
@@ -51,0 +53,0 @@ private _handleDragEnd; |
@@ -12,2 +12,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
}; | ||
import { debounce } from '../utils/utils'; | ||
import { ChangeEvent, Control, EditEvent } from "./Control"; | ||
@@ -48,2 +49,3 @@ import { move, pointToLineDistanceSquare } from "../geotools"; | ||
this._activeIndex = null; | ||
this._debouncedSnappingHandle = debounce(this._snappingHandle.bind(this), 50); | ||
this.onFeatureRemove = onFeatureRemove; | ||
@@ -159,3 +161,3 @@ this._handleMousemove = this._handleMousemove.bind(this); | ||
return this._handleFeatureDrag(event); | ||
this._activeFeature.setPoint(this._activeRing, this._activeIndex, this._snap(event.point.position, event.browserEvent.altKey, this._activeFeature.rings[this._activeRing], this._activeIndex, this._activeFeature instanceof Polygon)); | ||
this._activeFeature.setPoint(this._activeRing, this._activeIndex, event.point.position); | ||
this._activeFeature.redraw(); | ||
@@ -165,3 +167,15 @@ if (this.activeLayer) | ||
this.fire(new ChangeEvent(this._activeRing, this._activeIndex)); | ||
this._unsnap(); | ||
this._debouncedSnappingHandle(event); | ||
} | ||
_snappingHandle(event) { | ||
const snappingResult = this._snap(event.point.position, event.browserEvent.altKey, this._activeFeature.rings[this._activeRing], this._activeIndex, this._activeFeature instanceof Polygon); | ||
Promise.resolve(snappingResult).then((point) => { | ||
this._activeFeature.setPoint(this._activeRing, this._activeIndex, point || event.point.position); | ||
this._activeFeature.redraw(); | ||
if (this.activeLayer) | ||
this.activeLayer.redraw(); | ||
this.fire(new ChangeEvent(this._activeRing, this._activeIndex)); | ||
}); | ||
} | ||
get isDraggingVertex() { return this._activeRing !== null; } | ||
@@ -168,0 +182,0 @@ _handleDragEnd() { |
@@ -17,3 +17,3 @@ import { Contour, Coordinates } from "../../baseTypes"; | ||
*/ | ||
getSnappingPoint(point: Coordinates, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean): Coordinates | null; | ||
getSnappingPoint(point: Coordinates, activeContour?: Contour, activeIndex?: number, isPolygon?: boolean): Promise<Coordinates | null> | Coordinates | null; | ||
/** | ||
@@ -20,0 +20,0 @@ * Returns a copy of the given provider. This method is needed to create complex snapping providers, consisting |
@@ -149,4 +149,5 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
const indexDoesNotExistInCurrentBBox = !indexes.some((index) => TileLayer._getTileId(index.z, index.x, index.y) === tileId); | ||
if (indexDoesNotExistInCurrentBBox && !tile.isImageLoaded) { | ||
tile.deleteNode(); | ||
const itIsImageNodeNotLoaded = "src" in tile.node && !tile.node.complete; | ||
if (indexDoesNotExistInCurrentBBox && itIsImageNodeNotLoaded) { | ||
tile.node.src = ""; | ||
delete this._tileCache[tileId]; | ||
@@ -153,0 +154,0 @@ } |
@@ -127,4 +127,4 @@ import { Point } from "../../Point"; | ||
if (this._updateAllowed) { | ||
layers.reverse().forEach(layer => { | ||
let renderer = this._layerRenderers.get(layer); | ||
for (let i = layers.length - 1; i >= 0; i--) { | ||
let renderer = this._layerRenderers.get(layers[i]); | ||
if (redrawNeeded || renderer.updateNeeded) { | ||
@@ -139,3 +139,3 @@ try { | ||
} | ||
}); | ||
} | ||
this._redrawNeeded = false; | ||
@@ -142,0 +142,0 @@ } |
@@ -18,5 +18,2 @@ import { HTMLRasterElement, Offset } from "../baseTypes"; | ||
private _src; | ||
private _controller; | ||
private _complete; | ||
private _aborted; | ||
offset: Offset; | ||
@@ -35,4 +32,2 @@ onLoad?: () => void; | ||
set opacity(value: number); | ||
get isImageLoaded(): boolean; | ||
deleteNode(): void; | ||
} |
@@ -13,4 +13,2 @@ import { StaticRender } from "./Render"; | ||
this._src = src; | ||
this._complete = false; | ||
this._aborted = false; | ||
this._createNode(); | ||
@@ -25,14 +23,3 @@ } | ||
this._node.style.opacity = this._opacity.toString(); | ||
const controller = new AbortController(); | ||
const signal = controller.signal; | ||
this._controller = controller; | ||
this.readyPromise = loadImage(this._node, this._src, signal) | ||
.then(() => { | ||
this._complete = true; | ||
}) | ||
.catch((e) => { | ||
if (!this._aborted) { | ||
throw e; | ||
} | ||
}); | ||
this.readyPromise = loadImage(this._node, this._src); | ||
this.readyPromise.then(this.onLoad).catch(this.onError); | ||
@@ -64,9 +51,2 @@ } | ||
} | ||
get isImageLoaded() { | ||
return this._complete; | ||
} | ||
deleteNode() { | ||
this._aborted = true; | ||
this._controller.abort(); | ||
} | ||
} |
@@ -63,4 +63,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export declare const version = "0.5.0-alpha.23"; | ||
export declare const releaseDate = "12.07.2022"; | ||
export declare const version = "0.5.0-alpha.24"; | ||
export declare const releaseDate = "27.07.2022"; | ||
export declare const controls: { | ||
@@ -67,0 +67,0 @@ Circle: typeof Circle; |
@@ -65,4 +65,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export const version = "0.5.0-alpha.23"; | ||
export const releaseDate = "12.07.2022"; | ||
export const version = "0.5.0-alpha.24"; | ||
export const releaseDate = "27.07.2022"; | ||
let utilsModulesExt = {}; | ||
@@ -69,0 +69,0 @@ Object.assign(utilsModulesExt, utilsModule, { Color: Color }); |
@@ -125,3 +125,3 @@ import { registerSymbol } from "../../serializers/symbolSerializer"; | ||
this._image = new Image(); | ||
this.imageReadyPromise = loadImage(this._image, src, null); | ||
this.imageReadyPromise = loadImage(this._image, src); | ||
return this.imageReadyPromise; | ||
@@ -132,3 +132,3 @@ } | ||
this._mask = new Image(); | ||
this.maskReadyPromise = loadImage(this._mask, src, null); | ||
this.maskReadyPromise = loadImage(this._mask, src); | ||
return this.maskReadyPromise; | ||
@@ -135,0 +135,0 @@ } |
@@ -92,2 +92,2 @@ /** | ||
*/ | ||
export declare function loadImage(image: HTMLImageElement, src: string, signal: AbortSignal | null): Promise<void>; | ||
export declare function loadImage(image: HTMLImageElement, src: string): Promise<void>; |
@@ -213,9 +213,11 @@ /** | ||
*/ | ||
export function loadImage(image, src, signal) { | ||
return fetch(src, { signal }) | ||
.then((res) => res.blob()) | ||
.then((blob) => { | ||
const url = URL.createObjectURL(blob); | ||
image.src = url; | ||
export function loadImage(image, src) { | ||
image.src = src; | ||
return new Promise((res, rej) => { | ||
if (image.complete) { | ||
return res(); | ||
} | ||
image.onload = () => res(); | ||
image.onerror = error => rej(error); | ||
}); | ||
} |
{ | ||
"name": "@evergis/sgis", | ||
"version": "0.5.0-alpha.23", | ||
"version": "0.5.0-alpha.24", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/sGis_bundle.js", |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
2925711
36202
0