MCPcopy Index your code
hub / github.com/simstudioai/sim / goToSlide

Method goToSlide

apps/sim/lib/pptx-renderer/core/viewer.ts:276–302  ·  view source on GitHub ↗
(index: number, scrollOptions?: ScrollIntoViewOptions)

Source from the content-addressed store, hash-verified

274 // -----------------------------------------------------------------------
275
276 async goToSlide(index: number, scrollOptions?: ScrollIntoViewOptions): Promise<void> {
277 if (!this.presentation) return
278 const prev = this.currentSlide
279 this.currentSlide = Math.max(0, Math.min(index, this.presentation.slides.length - 1))
280 if (this.currentSlide !== prev) {
281 this.emitSlideChange(this.currentSlide)
282 }
283 if (this.activeRenderMode === 'slide') {
284 const { scale, displayWidth, displayHeight } = this.getDisplayMetrics()
285 this.renderSingleSlide(scale, displayWidth, displayHeight)
286 } else {
287 this.suppressScrollChange = true
288 await new Promise<void>((resolve) =>
289 requestAnimationFrame(() => {
290 this.suppressScrollChange = false
291 resolve()
292 })
293 )
294 this.ensureListSlideMountedFn?.(this.currentSlide)
295 const targetChild = this.container.querySelector<HTMLElement>(
296 `[data-slide-index="${this.currentSlide}"]`
297 )
298 if (targetChild) {
299 targetChild.scrollIntoView(scrollOptions ?? { behavior: 'smooth', block: 'center' })
300 }
301 }
302 }
303
304 async setZoom(percent: number): Promise<void> {
305 const normalized = this.normalizeZoomPercent(percent)

Callers 2

handleNavigateMethod · 0.95
goToSlideFunction · 0.80

Calls 4

emitSlideChangeMethod · 0.95
getDisplayMetricsMethod · 0.95
renderSingleSlideMethod · 0.95
resolveFunction · 0.50

Tested by

no test coverage detected