Merge pull request #1430 from Hans5958/live-love-life/2.1

Various "minor" changes (2.1)
This commit is contained in:
Stefano 2023-04-07 13:58:03 +02:00 committed by GitHub
commit 94a2cca165
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 32 deletions

View file

@ -398,22 +398,21 @@ async function init() {
)
function mousemove(x, y) {
if (dragging) {
container.style.cursor = "move"
if (!dragging) return
container.style.cursor = "move"
const deltaX = x - lastPosition[0]
const deltaY = y - lastPosition[1]
lastPosition = [x, y]
const deltaX = x - lastPosition[0]
const deltaY = y - lastPosition[1]
lastPosition = [x, y]
zoomOrigin[0] += deltaX
zoomOrigin[1] += deltaY
zoomOrigin[0] += deltaX
zoomOrigin[1] += deltaY
scaleZoomOrigin[0] += deltaX / zoom
scaleZoomOrigin[1] += deltaY / zoom
scaleZoomOrigin[0] += deltaX / zoom
scaleZoomOrigin[1] += deltaY / zoom
updateLines()
applyView()
}
updateLines()
applyView()
}
function touchmove(e) {

View file

@ -9,6 +9,9 @@ const linesCanvas = document.getElementById("linesCanvas")
const linesContext = linesCanvas.getContext("2d")
let hovered = []
let previousScaleZoomOrigin
let previousZoom
const backgroundCanvas = document.createElement("canvas")
backgroundCanvas.width = canvasSize.x
backgroundCanvas.height = canvasSize.y
@ -400,36 +403,40 @@ function buildObjectsList(filter = null, sort = null) {
const entry = sortedAtlas[i]
element.addEventListener("mouseenter", function () {
if (!fixed && !dragging) {
objectsContainer.replaceChildren()
if (fixed || dragging) return
objectsContainer.replaceChildren()
previousZoomOrigin = [zoomOrigin[0], zoomOrigin[1]]
previousScaleZoomOrigin = [scaleZoomOrigin[0], scaleZoomOrigin[1]]
previousScaleZoomOrigin ??= [...scaleZoomOrigin]
previousZoom ??= zoom
setView(entry.center[0], entry.center[1], setZoomByPath(entry.path))
applyView()
setView(entry.center[0], entry.center[1], setZoomByPath(entry.path))
hovered = [entry]
render()
hovered[0].element = this
updateLines()
}
hovered = [entry]
render()
hovered[0].element = this
updateLines()
})
element.addEventListener("click", e => {
toggleFixed(e)
if (fixed) {
applyView()
}
if (!fixed) return
previousScaleZoomOrigin ??= [...scaleZoomOrigin]
previousZoom ??= zoom
applyView()
})
element.addEventListener("mouseleave", function () {
if (!fixed && !dragging) {
hovered = []
updateLines()
render()
}
if (fixed || dragging) return
scaleZoomOrigin = [...previousScaleZoomOrigin]
zoom = previousZoom
previousScaleZoomOrigin = undefined
previousZoom = undefined
applyView()
hovered = []
updateLines()
render()
})
entriesList.appendChild(element)