Skip to content

Commit

Permalink
Fixed presentation transition getting skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
Developer-Mike committed Jan 13, 2025
1 parent aff37b9 commit ba1dc04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/canvas-extensions/presentation-canvas-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,14 @@ export default class PresentationCanvasExtension extends CanvasExtension {

await sleep(animationDurationMs / 2)

const nextNodeBBoxEnlarged = BBoxHelper.scaleBBox(toNode.getBBox(), animationIntensity)
if (useCustomZoomFunction) CanvasHelper.zoomToBBox(canvas, nextNodeBBoxEnlarged)
else canvas.zoomToBbox(nextNodeBBoxEnlarged)
if (fromNode.getData().id !== toNode.getData().id) {
// Add 0.1 to fix obsidian bug that causes the animation to skip if the bbox is the same
const nextNodeBBoxEnlarged = BBoxHelper.scaleBBox(toNode.getBBox(), animationIntensity + 0.1)
if (useCustomZoomFunction) CanvasHelper.zoomToBBox(canvas, nextNodeBBoxEnlarged)
else canvas.zoomToBbox(nextNodeBBoxEnlarged)

await sleep(animationDurationMs / 2)
await sleep(animationDurationMs / 2)
}
}

let nodeBBox = toNode.getBBox()
Expand Down
4 changes: 4 additions & 0 deletions src/utils/canvas-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export default class CanvasHelper {
}

static zoomToBBox(canvas: Canvas, bbox: BBox) {
/* const zoomX = canvas.canvasRect.width / (1.1 * (bbox.maxX - bbox.minX))
const zoomY = canvas.canvasRect.height / (1.1 * (bbox.maxY - bbox.minY))
const zoom = Math.clamp(Math.min(zoomX, zoomY), -4, 1) */

const PADDING_CORRECTION_FACTOR = 1 / 1.1
const zoomedBBox = BBoxHelper.scaleBBox(bbox, PADDING_CORRECTION_FACTOR)

Expand Down

0 comments on commit ba1dc04

Please sign in to comment.