Skip to content

Commit

Permalink
Merge pull request #1407 from placeAtlas/staging/code-minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans5958 committed Jul 29, 2023
2 parents 90a7626 + 83e91ac commit f403df7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions web/_js/main/draw.js
Expand Up @@ -810,9 +810,9 @@ function initDraw() {
const [,, hashX, hashY, hashZoom] = hash.split('/')

setView(
isNaN(hashX) ? center[0] : Number(hashX),
isNaN(hashY) ? center[1] : Number(hashY),
isNaN(hashZoom) ? 4 : Number(hashZoom)
(isNaN(hashX) || hashX === '') ? center[0] : Number(hashX),

Check notice on line 813 in web/_js/main/draw.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashY) || hashY === '') ? center[1] : Number(hashY),

Check notice on line 814 in web/_js/main/draw.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashZoom) || hashZoom === '') ? 4 : Number(hashZoom)

Check notice on line 815 in web/_js/main/draw.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
)

document.addEventListener('timeupdate', () => {
Expand Down
17 changes: 9 additions & 8 deletions web/_js/main/main.js
Expand Up @@ -41,6 +41,7 @@ function applyView() {

scaleZoomOrigin[0] = Math.max(-canvasCenter.x + canvasOffset.x, Math.min(canvasCenter.x - canvasOffset.x, scaleZoomOrigin[0]))
scaleZoomOrigin[1] = Math.max(-canvasCenter.y + canvasOffset.y, Math.min(canvasCenter.y - canvasOffset.y, scaleZoomOrigin[1]))
zoom = Math.max(minZoom, Math.min(maxZoom, zoom))

zoomOrigin = [scaleZoomOrigin[0] * zoom, scaleZoomOrigin[1] * zoom]

Expand All @@ -54,12 +55,12 @@ function applyView() {

function setView(targetX, targetY, targetZoom) {

if (isNaN(targetX)) targetX = undefined
if (isNaN(targetY)) targetY = undefined
if (isNaN(targetX)) targetX = null
if (isNaN(targetY)) targetY = null

zoom ??= targetZoom
if (targetX) scaleZoomOrigin[0] = canvasCenter.x - targetX
if (targetY) scaleZoomOrigin[1] = canvasCenter.y - targetY
zoom = targetZoom ?? zoom
if ((targetX ?? null) !== null) scaleZoomOrigin[0] = canvasCenter.x - targetX
if ((targetY ?? null) !== null) scaleZoomOrigin[1] = canvasCenter.y - targetY

applyView()

Expand Down Expand Up @@ -122,9 +123,9 @@ async function init() {
//console.log(document.documentElement.clientWidth, document.documentElement.clientHeight)

setView(
isNaN(hashX) ? canvasCenter.x : Number(hashX),
isNaN(hashY) ? canvasCenter.y : Number(hashY),
isNaN(hashZoom) ? zoom : Number(hashZoom)
(isNaN(hashX) || hashX === '') ? canvasCenter.x : Number(hashX),

Check notice on line 126 in web/_js/main/main.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashY) || hashY === '') ? canvasCenter.y : Number(hashY),

Check notice on line 127 in web/_js/main/main.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashZoom) || hashZoom === '') ? zoom : Number(hashZoom)

Check notice on line 128 in web/_js/main/main.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
)

let initialPinchDistance = 0
Expand Down
12 changes: 6 additions & 6 deletions web/_js/main/view.js
Expand Up @@ -669,9 +669,9 @@ function updateViewFromHash() {
updateTime(targetPeriod, targetVariation, true)

Check notice on line 669 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Result of method call returning a promise is ignored

Promise returned from updateTime is ignored

setView(
isNaN(hashX) ? undefined : Number(hashX),
isNaN(hashY) ? undefined : Number(hashY),
isNaN(hashZoom) ? undefined : Number(hashZoom)
(isNaN(hashX) || hashX === '') ? undefined : Number(hashX),

Check notice on line 672 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashY) || hashY === '') ? undefined : Number(hashY),

Check notice on line 673 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashZoom) || hashZoom === '') ? undefined : Number(hashZoom)

Check notice on line 674 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
)

if (!hashEntryId) return
Expand Down Expand Up @@ -704,9 +704,9 @@ function updateViewFromHash() {

renderBackground(atlas)
setView(
isNaN(hashX) ? entry.center[0] : Number(hashX),
isNaN(hashY) ? entry.center[1] : Number(hashY),
isNaN(hashZoom) ? setZoomByPath(entry.path) : Number(hashZoom)
(isNaN(hashX) || hashX === '') ? entry.center[0] : Number(hashX),

Check notice on line 707 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashY) || hashY === '') ? entry.center[1] : Number(hashY),

Check notice on line 708 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
(isNaN(hashZoom) || hashZoom === '') ? setZoomByPath(entry.path) : Number(hashZoom)

Check notice on line 709 in web/_js/main/view.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Signature mismatch

Argument type string is not assignable to parameter type number
)

closeObjectsListButton.classList.remove("d-none")
Expand Down

0 comments on commit f403df7

Please sign in to comment.