Try to simplify the PDFSinglePageViewer._scrollIntoView method slightly, by unconditionally ensuring that rendering always occurs
				
					
				
			This commit is contained in:
		
							parent
							
								
									06cda4c2e7
								
							
						
					
					
						commit
						48e4adf770
					
				| @ -39,6 +39,7 @@ class PDFSinglePageViewer extends BaseViewer { | |||||||
|     super._resetView(); |     super._resetView(); | ||||||
|     this._previousPageNumber = 1; |     this._previousPageNumber = 1; | ||||||
|     this._shadowViewer = document.createDocumentFragment(); |     this._shadowViewer = document.createDocumentFragment(); | ||||||
|  |     this._updateScrollDown = null; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   _ensurePageViewVisible() { |   _ensurePageViewVisible() { | ||||||
| @ -82,9 +83,12 @@ class PDFSinglePageViewer extends BaseViewer { | |||||||
|     if (pageNumber) { // Ensure that `this._currentPageNumber` is correct.
 |     if (pageNumber) { // Ensure that `this._currentPageNumber` is correct.
 | ||||||
|       this._setCurrentPageNumber(pageNumber); |       this._setCurrentPageNumber(pageNumber); | ||||||
|     } |     } | ||||||
|     let scrolledDown = this._currentPageNumber >= this._previousPageNumber; |     const scrolledDown = this._currentPageNumber >= this._previousPageNumber; | ||||||
|     let previousLocation = this._location; | 
 | ||||||
|     this._ensurePageViewVisible(); |     this._ensurePageViewVisible(); | ||||||
|  |     // Ensure that rendering always occurs, to avoid showing a blank page,
 | ||||||
|  |     // even if the current position doesn't change when the page is scrolled.
 | ||||||
|  |     this.update(); | ||||||
| 
 | 
 | ||||||
|     super._scrollIntoView({ pageDiv, pageSpot, pageNumber, }); |     super._scrollIntoView({ pageDiv, pageSpot, pageNumber, }); | ||||||
| 
 | 
 | ||||||
| @ -92,18 +96,8 @@ class PDFSinglePageViewer extends BaseViewer { | |||||||
|     // scroll direction during the next `this._scrollUpdate` invocation.
 |     // scroll direction during the next `this._scrollUpdate` invocation.
 | ||||||
|     this._updateScrollDown = () => { |     this._updateScrollDown = () => { | ||||||
|       this.scroll.down = scrolledDown; |       this.scroll.down = scrolledDown; | ||||||
|       delete this._updateScrollDown; |       this._updateScrollDown = null; | ||||||
|     }; |     }; | ||||||
|     // If the scroll position doesn't change as a result of the `scrollIntoView`
 |  | ||||||
|     // call, ensure that rendering always occurs to avoid showing a blank page.
 |  | ||||||
|     setTimeout(() => { |  | ||||||
|       if (this._location === previousLocation) { |  | ||||||
|         if (this._updateScrollDown) { |  | ||||||
|           this._updateScrollDown(); |  | ||||||
|         } |  | ||||||
|         this.update(); |  | ||||||
|       } |  | ||||||
|     }, 0); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   _getVisiblePages() { |   _getVisiblePages() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user