Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
fix: canvas jump on drag — scrollbar appearance was reflowing the centred stage
nyblnete91d53fbf8e5
diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.tsindex 5a5f3888..5fc6322a 100644--- a/slides/src/editor/canvas.ts+++ b/slides/src/editor/canvas.ts@@ -125,8 +125,18 @@ export class SlideCanvas {this.scroller.scrollTop = lockT}})- const lockScroll = () => { gestureLock = true; lockL = this.scroller.scrollLeft; lockT = this.scroller.scrollTop }- const unlockScroll = () => { gestureLock = false }+ const lockScroll = () => {+ gestureLock = true+ lockL = this.scroller.scrollLeft+ lockT = this.scroller.scrollTop+ // the REAL jump culprit: a scrollbar APPEARING mid-drag (guideline overflow)+ // shrinks the client box and re-centres the stage. If no bar is showing at+ // gesture start, forbid overflow for the drag so one can never appear.+ // (scrollbar-gutter covers the vertical bar; this covers horizontal too.)+ const s = this.scroller+ if (s.scrollHeight <= s.clientHeight && s.scrollWidth <= s.clientWidth) s.style.overflow = 'hidden'+ }+ const unlockScroll = () => { gestureLock = false; this.scroller.style.overflow = '' }for (const e of ['dragStart', 'resizeStart', 'rotateStart', 'dragGroupStart', 'resizeGroupStart', 'rotateGroupStart'])(this.moveable as unknown as { on: (e: string, f: () => void) => void }).on(e, lockScroll)for (const e of ['dragEnd', 'resizeEnd', 'rotateEnd', 'dragGroupEnd', 'resizeGroupEnd', 'rotateGroupEnd'])diff --git a/slides/src/styles.css b/slides/src/styles.cssindex 9990cb39..6bfb0990 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -223,6 +223,9 @@ html, body {inset: 0;overflow: auto;display: flex;+ /* classic (non-overlay) scrollbars: reserve the gutter so a bar appearing+ mid-drag can't shrink the client box and shove the centred stage around */+ scrollbar-gutter: stable both-edges;}.ed-stage {