double click working

This commit is contained in:
Luis Fernando Molina committed 2020-03-07 19:08:01 +01:00
1 parent ba66db2907
commit 8090745478
3 files changed
+12 -11

No files matched your search

+2 -6
View File
@@ -106,12 +106,8 @@ function newEdgeEditor () {
function onDoubleClick () {
doubleClickCounter = 0
canvas.chartingSpace.viewport.displaceToContainer(thisObject.container.parentContainer)
if (canvas.chartingSpace.viewport.zoomLevel === DOUBLE_CLICK_ZOOM_IN_LEVEL) {
canvas.chartingSpace.viewport.zoomAtCenter(DOUBLE_CLICK_ZOOM_OUT_LEVEL)
} else {
if (canvas.chartingSpace.viewport.zoomLevel === DOUBLE_CLICK_ZOOM_OUT_LEVEL) {
canvas.chartingSpace.viewport.displaceToContainer(thisObject.container.parentContainer)
canvas.chartingSpace.viewport.zoomAtCenter(DOUBLE_CLICK_ZOOM_IN_LEVEL)
}
}
+9 -4
View File
@@ -146,6 +146,7 @@ function newViewport () {
function zoomAtCenter (level) {
thisObject.zoomTargetLevel = level
overrideMousePositionCounter = 50
ANIMATION_INCREMENT = 0.5
}
function mousePositionPhysics () {
@@ -153,7 +154,7 @@ function newViewport () {
thisObject.mousePosition.x = browserCanvas.width / 2
thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT) / 2 - TOP_SPACE_HEIGHT / 2
console.log('SETTING MOUSE TO CENTER', overrideMousePositionCounter, thisObject.zoomLevel, thisObject.zoomTargetLevel)
console.log('SETTING MOUSE TO CENTER ', 'COUNTER ' + overrideMousePositionCounter, 'zoomLevel ' + thisObject.zoomLevel, 'zoomTargetLevel ' + thisObject.zoomTargetLevel)
overrideMousePositionCounter--
if (overrideMousePositionCounter < 0) {
overrideMousePositionCounter = 0
@@ -185,6 +186,8 @@ function newViewport () {
}
thisObject.zoomLevel = Math.round((thisObject.zoomLevel + ANIMATION_INCREMENT) * 100) / 100
changeZoom(thisObject.zoomLevel - ANIMATION_INCREMENT, thisObject.zoomLevel)
console.log('ANIMATION_INCREMENT ' + ANIMATION_INCREMENT)
}
if (thisObject.zoomLevel > thisObject.zoomTargetLevel) {
@@ -193,6 +196,8 @@ function newViewport () {
}
thisObject.zoomLevel = Math.round((thisObject.zoomLevel - ANIMATION_INCREMENT) * 100) / 100
changeZoom(thisObject.zoomLevel + ANIMATION_INCREMENT, thisObject.zoomLevel)
console.log('ANIMATION_INCREMENT ' + ANIMATION_INCREMENT)
}
}
@@ -222,9 +227,9 @@ function newViewport () {
if (thisObject.zoomTargetLevel + amount * morePower < MIN_ZOOM_LEVEL) {
return false
}
thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount * morePower
thisObject.zoomTargetLevel = Math.round(thisObject.zoomTargetLevel + amount * morePower)
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS
ANIMATION_INCREMENT = Math.round(Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS * 100) / 100
let newEvent = {
newLevel: thisObject.zoomTargetLevel,
@@ -305,7 +310,7 @@ function newViewport () {
saveObjectState()
console.log('ZOOM LEVEL CHANGED', oldLevel, newLevel)
console.log('ZOOM LEVEL CHANGED', 'oldLevel = ' + oldLevel, 'newLevel = ' + newLevel)
thisObject.eventHandler.raiseEvent('Zoom Changed')
}
+1 -1
View File
@@ -169,7 +169,7 @@ const _2_MINUTES_IN_MILISECONDS = 2 * 60 * 1000;
const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000;
const DOUBLE_CLICK_ZOOM_OUT_LEVEL = 0
const DOUBLE_CLICK_ZOOM_IN_LEVEL = 7
const DOUBLE_CLICK_ZOOM_IN_LEVEL = 8
let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the canvas.chartingSpace.viewport.initialize if the user had a prevous session with this same browser.
let INITIAL_ZOOM_LEVEL = -28.25 // This is the zoom level at the view port in which the APP starts.