26 lines
746 B
JavaScript
26 lines
746 B
JavaScript
const serializedCoordinateTolerance = 1e-6
|
|
|
|
export const shouldApplyInitialViewport = initializedViewport => !initializedViewport
|
|
|
|
export const viewportMatchesBounds = (viewport, bounds) => {
|
|
if (!viewport || !bounds) return false
|
|
|
|
return [
|
|
[viewport.west, bounds.getWest()],
|
|
[viewport.south, bounds.getSouth()],
|
|
[viewport.east, bounds.getEast()],
|
|
[viewport.north, bounds.getNorth()]
|
|
].every(
|
|
([saved, current]) =>
|
|
Number.isFinite(saved) &&
|
|
Number.isFinite(current) &&
|
|
Math.abs(saved - current) <= serializedCoordinateTolerance
|
|
)
|
|
}
|
|
|
|
export const mapSizeChanged = (previous, current) => {
|
|
if (!previous) return true
|
|
|
|
return previous.width !== current.width || previous.height !== current.height
|
|
}
|