almost there
This commit is contained in:
1 parent
72a12c346b
commit
ba66db2907
3 files changed
+19
-8
No files matched your search
@@ -107,7 +107,7 @@ function newEdgeEditor () {
|
||||
function onDoubleClick () {
|
||||
doubleClickCounter = 0
|
||||
|
||||
// canvas.chartingSpace.viewport.displaceToContainer(thisObject.container.parentContainer)
|
||||
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)
|
||||
|
||||
@@ -40,6 +40,7 @@ function newViewport () {
|
||||
fitIntoVisibleArea: fitIntoVisibleArea,
|
||||
fitIntoViewport: fitIntoViewport,
|
||||
displace: displace,
|
||||
displaceToContainer: displaceToContainer,
|
||||
physics: physics,
|
||||
raiseEvents: raiseEvents,
|
||||
resize: resize,
|
||||
@@ -133,10 +134,24 @@ function newViewport () {
|
||||
thisObject.eventHandler.raiseEvent('Position Changed', event)
|
||||
}
|
||||
|
||||
function displaceToContainer (container) {
|
||||
let targetPoint = {
|
||||
x: -container.frame.position.x - container.frame.width / 2,
|
||||
y: -container.frame.position.y - container.frame.height / 2 + TOP_SPACE_HEIGHT
|
||||
}
|
||||
position.x = targetPoint.x + thisObject.width / 2
|
||||
position.y = targetPoint.y + thisObject.height / 2
|
||||
}
|
||||
|
||||
function zoomAtCenter (level) {
|
||||
thisObject.zoomTargetLevel = level
|
||||
overrideMousePositionCounter = 50
|
||||
}
|
||||
|
||||
function mousePositionPhysics () {
|
||||
if (overrideMousePositionCounter > 0) {
|
||||
thisObject.mousePosition.x = browserCanvas.width / 2
|
||||
thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT) / 2 + TOP_SPACE_HEIGHT
|
||||
thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT) / 2 - TOP_SPACE_HEIGHT / 2
|
||||
|
||||
console.log('SETTING MOUSE TO CENTER', overrideMousePositionCounter, thisObject.zoomLevel, thisObject.zoomTargetLevel)
|
||||
overrideMousePositionCounter--
|
||||
@@ -280,11 +295,6 @@ function newViewport () {
|
||||
thisObject.eventHandler.raiseEvent('Position Changed', event)
|
||||
}
|
||||
|
||||
function zoomAtCenter (level) {
|
||||
thisObject.zoomTargetLevel = level
|
||||
overrideMousePositionCounter = 10
|
||||
}
|
||||
|
||||
function changeZoom (oldLevel, newLevel) {
|
||||
if (thisObject.visible === false) { return }
|
||||
let oldMouse = unTransformThisPoint(thisObject.mousePosition, oldLevel)
|
||||
@@ -406,3 +416,4 @@ function newViewport () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user