Store the rotation in the PDFHistory
				
					
				
			This commit is contained in:
		
							parent
							
								
									44d5138d0f
								
							
						
					
					
						commit
						e135c03123
					
				@ -935,6 +935,8 @@ let PDFViewerApplication = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (this.pdfHistory.initialBookmark) {
 | 
					        if (this.pdfHistory.initialBookmark) {
 | 
				
			||||||
          this.initialBookmark = this.pdfHistory.initialBookmark;
 | 
					          this.initialBookmark = this.pdfHistory.initialBookmark;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          this.initialRotation = this.pdfHistory.initialRotation;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1145,6 +1147,9 @@ let PDFViewerApplication = {
 | 
				
			|||||||
    this.pdfSidebar.setInitialView(sidebarView);
 | 
					    this.pdfSidebar.setInitialView(sidebarView);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this.initialBookmark) {
 | 
					    if (this.initialBookmark) {
 | 
				
			||||||
 | 
					      setRotation(this.initialRotation);
 | 
				
			||||||
 | 
					      delete this.initialRotation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.pdfLinkService.setHash(this.initialBookmark);
 | 
					      this.pdfLinkService.setHash(this.initialBookmark);
 | 
				
			||||||
      this.initialBookmark = null;
 | 
					      this.initialBookmark = null;
 | 
				
			||||||
    } else if (storedHash) {
 | 
					    } else if (storedHash) {
 | 
				
			||||||
 | 
				
			|||||||
@ -30,6 +30,16 @@ class IPDFLinkService {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  set page(value) {}
 | 
					  set page(value) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @returns {number}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  get rotation() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @param {number} value
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  set rotation(value) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * @param dest - The PDF destination object.
 | 
					   * @param dest - The PDF destination object.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,9 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { cloneObj, parseQueryString, waitOnEventOrTimeout } from './ui_utils';
 | 
					import {
 | 
				
			||||||
 | 
					  cloneObj, isValidRotation, parseQueryString, waitOnEventOrTimeout
 | 
				
			||||||
 | 
					} from './ui_utils';
 | 
				
			||||||
import { getGlobalEventBus } from './dom_events';
 | 
					import { getGlobalEventBus } from './dom_events';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Heuristic value used when force-resetting `this._blockHashChange`.
 | 
					// Heuristic value used when force-resetting `this._blockHashChange`.
 | 
				
			||||||
@ -49,7 +51,7 @@ function parseCurrentHash(linkService) {
 | 
				
			|||||||
  if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
 | 
					  if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
 | 
				
			||||||
    page = null;
 | 
					    page = null;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return { hash, page, };
 | 
					  return { hash, page, rotation: linkService.rotation, };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PDFHistory {
 | 
					class PDFHistory {
 | 
				
			||||||
@ -62,6 +64,7 @@ class PDFHistory {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    this.initialized = false;
 | 
					    this.initialized = false;
 | 
				
			||||||
    this.initialBookmark = null;
 | 
					    this.initialBookmark = null;
 | 
				
			||||||
 | 
					    this.initialRotation = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this._boundEvents = Object.create(null);
 | 
					    this._boundEvents = Object.create(null);
 | 
				
			||||||
    this._isViewerInPresentationMode = false;
 | 
					    this._isViewerInPresentationMode = false;
 | 
				
			||||||
@ -99,6 +102,7 @@ class PDFHistory {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    this.initialized = true;
 | 
					    this.initialized = true;
 | 
				
			||||||
    this.initialBookmark = null;
 | 
					    this.initialBookmark = null;
 | 
				
			||||||
 | 
					    this.initialRotation = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this._popStateInProgress = false;
 | 
					    this._popStateInProgress = false;
 | 
				
			||||||
    this._blockHashChange = 0;
 | 
					    this._blockHashChange = 0;
 | 
				
			||||||
@ -110,7 +114,7 @@ class PDFHistory {
 | 
				
			|||||||
    this._position = null;
 | 
					    this._position = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!this._isValidState(state) || resetHistory) {
 | 
					    if (!this._isValidState(state) || resetHistory) {
 | 
				
			||||||
      let { hash, page, } = parseCurrentHash(this.linkService);
 | 
					      let { hash, page, rotation, } = parseCurrentHash(this.linkService);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!hash || reInitialized || resetHistory) {
 | 
					      if (!hash || reInitialized || resetHistory) {
 | 
				
			||||||
        // Ensure that the browser history is reset on PDF document load.
 | 
					        // Ensure that the browser history is reset on PDF document load.
 | 
				
			||||||
@ -119,7 +123,8 @@ class PDFHistory {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      // Ensure that the browser history is initialized correctly when
 | 
					      // Ensure that the browser history is initialized correctly when
 | 
				
			||||||
      // the document hash is present on PDF document load.
 | 
					      // the document hash is present on PDF document load.
 | 
				
			||||||
      this._pushOrReplaceState({ hash, page, }, /* forceReplace = */ true);
 | 
					      this._pushOrReplaceState({ hash, page, rotation, },
 | 
				
			||||||
 | 
					                               /* forceReplace = */ true);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -128,6 +133,10 @@ class PDFHistory {
 | 
				
			|||||||
    let destination = state.destination;
 | 
					    let destination = state.destination;
 | 
				
			||||||
    this._updateInternalState(destination, state.uid,
 | 
					    this._updateInternalState(destination, state.uid,
 | 
				
			||||||
                              /* removeTemporary = */ true);
 | 
					                              /* removeTemporary = */ true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (destination.rotation !== undefined) {
 | 
				
			||||||
 | 
					      this.initialRotation = destination.rotation;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (destination.dest) {
 | 
					    if (destination.dest) {
 | 
				
			||||||
      this.initialBookmark = JSON.stringify(destination.dest);
 | 
					      this.initialBookmark = JSON.stringify(destination.dest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -188,6 +197,7 @@ class PDFHistory {
 | 
				
			|||||||
      dest: explicitDest,
 | 
					      dest: explicitDest,
 | 
				
			||||||
      hash,
 | 
					      hash,
 | 
				
			||||||
      page: pageNumber,
 | 
					      page: pageNumber,
 | 
				
			||||||
 | 
					      rotation: this.linkService.rotation,
 | 
				
			||||||
    }, forceReplace);
 | 
					    }, forceReplace);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!this._popStateInProgress) {
 | 
					    if (!this._popStateInProgress) {
 | 
				
			||||||
@ -402,6 +412,7 @@ class PDFHistory {
 | 
				
			|||||||
        `page=${location.pageNumber}` : location.pdfOpenParams.substring(1),
 | 
					        `page=${location.pageNumber}` : location.pdfOpenParams.substring(1),
 | 
				
			||||||
      page: this.linkService.page,
 | 
					      page: this.linkService.page,
 | 
				
			||||||
      first: location.pageNumber,
 | 
					      first: location.pageNumber,
 | 
				
			||||||
 | 
					      rotation: location.rotation,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this._popStateInProgress) {
 | 
					    if (this._popStateInProgress) {
 | 
				
			||||||
@ -459,8 +470,9 @@ class PDFHistory {
 | 
				
			|||||||
      // This case corresponds to the user changing the hash of the document.
 | 
					      // This case corresponds to the user changing the hash of the document.
 | 
				
			||||||
      this._currentUid = this._uid;
 | 
					      this._currentUid = this._uid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let { hash, page, } = parseCurrentHash(this.linkService);
 | 
					      let { hash, page, rotation, } = parseCurrentHash(this.linkService);
 | 
				
			||||||
      this._pushOrReplaceState({ hash, page, }, /* forceReplace */ true);
 | 
					      this._pushOrReplaceState({ hash, page, rotation, },
 | 
				
			||||||
 | 
					                               /* forceReplace = */ true);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!this._isValidState(state)) {
 | 
					    if (!this._isValidState(state)) {
 | 
				
			||||||
@ -497,6 +509,10 @@ class PDFHistory {
 | 
				
			|||||||
    let destination = state.destination;
 | 
					    let destination = state.destination;
 | 
				
			||||||
    this._updateInternalState(destination, state.uid,
 | 
					    this._updateInternalState(destination, state.uid,
 | 
				
			||||||
                              /* removeTemporary = */ true);
 | 
					                              /* removeTemporary = */ true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (isValidRotation(destination.rotation)) {
 | 
				
			||||||
 | 
					      this.linkService.rotation = destination.rotation;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (destination.dest) {
 | 
					    if (destination.dest) {
 | 
				
			||||||
      this.linkService.navigateTo(destination.dest);
 | 
					      this.linkService.navigateTo(destination.dest);
 | 
				
			||||||
    } else if (destination.hash) {
 | 
					    } else if (destination.hash) {
 | 
				
			||||||
 | 
				
			|||||||
@ -75,6 +75,20 @@ class PDFLinkService {
 | 
				
			|||||||
    this.pdfViewer.currentPageNumber = value;
 | 
					    this.pdfViewer.currentPageNumber = value;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @returns {number}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  get rotation() {
 | 
				
			||||||
 | 
					    return this.pdfViewer.pagesRotation;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @param {number} value
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  set rotation(value) {
 | 
				
			||||||
 | 
					    this.pdfViewer.pagesRotation = value;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * @param {string|Array} dest - The named, or explicit, PDF destination.
 | 
					   * @param {string|Array} dest - The named, or explicit, PDF destination.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
@ -414,6 +428,16 @@ class SimpleLinkService {
 | 
				
			|||||||
   * @param {number} value
 | 
					   * @param {number} value
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  set page(value) {}
 | 
					  set page(value) {}
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @returns {number}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  get rotation() {
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @param {number} value
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  set rotation(value) {}
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * @param dest - The PDF destination object.
 | 
					   * @param dest - The PDF destination object.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user