File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,19 @@ export default (target: Element, options: Options): CustomScrollAction[] => {
383383 borderBottom
384384 : 0
385385
386+ const scaleX =
387+ 'offsetWidth' in frame
388+ ? ( frame as HTMLElement ) . offsetWidth === 0
389+ ? 0
390+ : width / ( frame as HTMLElement ) . offsetWidth
391+ : 0
392+ const scaleY =
393+ 'offsetHeight' in frame
394+ ? ( frame as HTMLElement ) . offsetHeight === 0
395+ ? 0
396+ : height / ( frame as HTMLElement ) . offsetHeight
397+ : 0
398+
386399 if ( scrollingElement === frame ) {
387400 // Handle viewport logic (document.documentElement or document.body)
388401
@@ -478,15 +491,15 @@ export default (target: Element, options: Options): CustomScrollAction[] => {
478491 blockScroll = Math . max (
479492 0 ,
480493 Math . min (
481- scrollTop + blockScroll ,
482- frame . scrollHeight - height + scrollbarHeight
494+ scrollTop + blockScroll / scaleY ,
495+ frame . scrollHeight - height / scaleY + scrollbarHeight
483496 )
484497 )
485498 inlineScroll = Math . max (
486499 0 ,
487500 Math . min (
488- scrollLeft + inlineScroll ,
489- frame . scrollWidth - width + scrollbarWidth
501+ scrollLeft + inlineScroll / scaleX ,
502+ frame . scrollWidth - width / scaleX + scrollbarWidth
490503 )
491504 )
492505
You can’t perform that action at this time.
0 commit comments