@@ -210,35 +210,34 @@ export default class PresentationCanvasExtension extends CanvasExtension {
210210 if ( isStartNode ) canvas . metadata [ 'startNode' ] = groupNode . getData ( ) . id
211211 }
212212
213- private async animateNodeTransition ( canvas : Canvas , fromNode : CanvasNode | undefined , toNode : CanvasNode ) {
214- const useCustomZoomFunction = this . plugin . settings . getSetting ( 'zoomToSlideWithoutPadding' )
213+ private async animateNodeTransition ( canvas : Canvas , fromNode : CanvasNode | undefined , toNode : CanvasNode ) {
214+ const removePadding = this . plugin . settings . getSetting ( 'zoomToSlideWithoutPadding' )
215215 const animationDurationMs = this . plugin . settings . getSetting ( 'slideTransitionAnimationDuration' ) * 1000
216216
217217 const toNodeBBox = CanvasHelper . getSmallestAllowedZoomBBox ( canvas , toNode . getBBox ( ) )
218+ const toNodeBBoxPadded = removePadding ? toNodeBBox : BBoxHelper . enlargeBBox ( toNodeBBox , 50 )
219+ console . log ( { toNodeBBox, toNodeBBoxPadded } )
218220
219221 if ( animationDurationMs > 0 && fromNode ) {
220222 const animationIntensity = this . plugin . settings . getSetting ( 'slideTransitionAnimationIntensity' )
221223
222224 const fromNodeBBox = CanvasHelper . getSmallestAllowedZoomBBox ( canvas , fromNode . getBBox ( ) )
225+ const fromNodeBBoxPadded = removePadding ? fromNodeBBox : BBoxHelper . enlargeBBox ( fromNodeBBox , 50 )
223226
224- const currentNodeBBoxEnlarged = BBoxHelper . scaleBBox ( fromNodeBBox , animationIntensity )
225- if ( useCustomZoomFunction ) canvas . zoomToRealBbox ( currentNodeBBoxEnlarged )
226- else canvas . zoomToBbox ( currentNodeBBoxEnlarged )
227+ const currentNodeBBoxEnlarged = BBoxHelper . scaleBBox ( fromNodeBBoxPadded , animationIntensity )
228+ canvas . zoomToRealBbox ( currentNodeBBoxEnlarged )
227229
228230 await sleep ( animationDurationMs / 2 )
229231
230232 if ( fromNode . getData ( ) . id !== toNode . getData ( ) . id ) {
231- // Add 0.1 to fix obsidian bug that causes the animation to skip if the bbox is the same
232- const nextNodeBBoxEnlarged = BBoxHelper . scaleBBox ( toNodeBBox , animationIntensity + 0.1 )
233- if ( useCustomZoomFunction ) canvas . zoomToRealBbox ( nextNodeBBoxEnlarged )
234- else canvas . zoomToBbox ( nextNodeBBoxEnlarged )
233+ const nextNodeBBoxEnlarged = BBoxHelper . scaleBBox ( toNodeBBoxPadded , animationIntensity )
234+ canvas . zoomToRealBbox ( nextNodeBBoxEnlarged )
235235
236236 await sleep ( animationDurationMs / 2 )
237237 }
238238 }
239239
240- if ( useCustomZoomFunction ) canvas . zoomToRealBbox ( toNodeBBox )
241- else canvas . zoomToBbox ( toNodeBBox )
240+ canvas . zoomToRealBbox ( toNodeBBoxPadded )
242241 }
243242
244243 private async startPresentation ( canvas : Canvas , tryContinue : boolean = false ) {
0 commit comments