mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-12-29 11:34:37 +01:00
Merge pull request #1430 from Hans5958/live-love-life/2.1
Various "minor" changes (2.1)
This commit is contained in:
commit
94a2cca165
2 changed files with 38 additions and 32 deletions
|
@ -398,22 +398,21 @@ async function init() {
|
||||||
)
|
)
|
||||||
|
|
||||||
function mousemove(x, y) {
|
function mousemove(x, y) {
|
||||||
if (dragging) {
|
if (!dragging) return
|
||||||
container.style.cursor = "move"
|
container.style.cursor = "move"
|
||||||
|
|
||||||
const deltaX = x - lastPosition[0]
|
const deltaX = x - lastPosition[0]
|
||||||
const deltaY = y - lastPosition[1]
|
const deltaY = y - lastPosition[1]
|
||||||
lastPosition = [x, y]
|
lastPosition = [x, y]
|
||||||
|
|
||||||
zoomOrigin[0] += deltaX
|
zoomOrigin[0] += deltaX
|
||||||
zoomOrigin[1] += deltaY
|
zoomOrigin[1] += deltaY
|
||||||
|
|
||||||
scaleZoomOrigin[0] += deltaX / zoom
|
scaleZoomOrigin[0] += deltaX / zoom
|
||||||
scaleZoomOrigin[1] += deltaY / zoom
|
scaleZoomOrigin[1] += deltaY / zoom
|
||||||
|
|
||||||
updateLines()
|
updateLines()
|
||||||
applyView()
|
applyView()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function touchmove(e) {
|
function touchmove(e) {
|
||||||
|
|
|
@ -9,6 +9,9 @@ const linesCanvas = document.getElementById("linesCanvas")
|
||||||
const linesContext = linesCanvas.getContext("2d")
|
const linesContext = linesCanvas.getContext("2d")
|
||||||
let hovered = []
|
let hovered = []
|
||||||
|
|
||||||
|
let previousScaleZoomOrigin
|
||||||
|
let previousZoom
|
||||||
|
|
||||||
const backgroundCanvas = document.createElement("canvas")
|
const backgroundCanvas = document.createElement("canvas")
|
||||||
backgroundCanvas.width = canvasSize.x
|
backgroundCanvas.width = canvasSize.x
|
||||||
backgroundCanvas.height = canvasSize.y
|
backgroundCanvas.height = canvasSize.y
|
||||||
|
@ -400,36 +403,40 @@ function buildObjectsList(filter = null, sort = null) {
|
||||||
const entry = sortedAtlas[i]
|
const entry = sortedAtlas[i]
|
||||||
|
|
||||||
element.addEventListener("mouseenter", function () {
|
element.addEventListener("mouseenter", function () {
|
||||||
if (!fixed && !dragging) {
|
if (fixed || dragging) return
|
||||||
objectsContainer.replaceChildren()
|
objectsContainer.replaceChildren()
|
||||||
|
|
||||||
previousZoomOrigin = [zoomOrigin[0], zoomOrigin[1]]
|
previousScaleZoomOrigin ??= [...scaleZoomOrigin]
|
||||||
previousScaleZoomOrigin = [scaleZoomOrigin[0], scaleZoomOrigin[1]]
|
previousZoom ??= zoom
|
||||||
|
setView(entry.center[0], entry.center[1], setZoomByPath(entry.path))
|
||||||
|
|
||||||
applyView()
|
hovered = [entry]
|
||||||
setView(entry.center[0], entry.center[1], setZoomByPath(entry.path))
|
render()
|
||||||
|
hovered[0].element = this
|
||||||
hovered = [entry]
|
updateLines()
|
||||||
render()
|
|
||||||
hovered[0].element = this
|
|
||||||
updateLines()
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
element.addEventListener("click", e => {
|
element.addEventListener("click", e => {
|
||||||
toggleFixed(e)
|
toggleFixed(e)
|
||||||
if (fixed) {
|
if (!fixed) return
|
||||||
applyView()
|
previousScaleZoomOrigin ??= [...scaleZoomOrigin]
|
||||||
}
|
previousZoom ??= zoom
|
||||||
|
applyView()
|
||||||
})
|
})
|
||||||
|
|
||||||
element.addEventListener("mouseleave", function () {
|
element.addEventListener("mouseleave", function () {
|
||||||
if (!fixed && !dragging) {
|
if (fixed || dragging) return
|
||||||
hovered = []
|
|
||||||
updateLines()
|
scaleZoomOrigin = [...previousScaleZoomOrigin]
|
||||||
render()
|
zoom = previousZoom
|
||||||
}
|
previousScaleZoomOrigin = undefined
|
||||||
|
previousZoom = undefined
|
||||||
|
applyView()
|
||||||
|
|
||||||
|
hovered = []
|
||||||
|
updateLines()
|
||||||
|
render()
|
||||||
})
|
})
|
||||||
|
|
||||||
entriesList.appendChild(element)
|
entriesList.appendChild(element)
|
||||||
|
|
Loading…
Reference in a new issue