-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: Preload for presentation viewer #12
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ import pageNumTemplate from './pageNumButtonContent.html'; | |
import DocBase from './DocBase'; | ||
import DocPreloader from './DocPreloader'; | ||
import fullscreen from '../../Fullscreen'; | ||
import { getRepresentation } from '../../file'; | ||
import { PRELOAD_REP_NAME } from '../../constants'; | ||
import { | ||
ICON_DROP_DOWN, | ||
ICON_DROP_UP, | ||
|
@@ -31,8 +29,8 @@ class Document extends DocBase { | |
this.docEl.classList.add('bp-doc-document'); | ||
|
||
// Set up preloader | ||
this.docPreloader = new DocPreloader(); | ||
this.docPreloader.addListener('preload', () => { | ||
this.preloader = new DocPreloader(); | ||
this.preloader.addListener('preload', () => { | ||
this.options.logger.setPreloaded(); | ||
}); | ||
} | ||
|
@@ -42,34 +40,7 @@ class Document extends DocBase { | |
*/ | ||
destroy() { | ||
super.destroy(); | ||
this.docPreloader.removeAllListeners('preload'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
showPreload() { | ||
// Don't show preload if there's a cached page since preloads are only for the 1st page | ||
if (this.getCachedPage() !== 1) { | ||
return; | ||
} | ||
|
||
const { file } = this.options; | ||
const preloadRep = getRepresentation(file, PRELOAD_REP_NAME); | ||
if (!preloadRep || !this.getViewerOption('preload')) { | ||
return; | ||
} | ||
|
||
const { url_template: template } = preloadRep.content; | ||
const preloadUrlWithAuth = this.createContentUrlWithAuthParams(template); | ||
this.docPreloader.showPreload(preloadUrlWithAuth, this.containerEl); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
hidePreload() { | ||
this.docPreloader.hidePreload(); | ||
this.preloader.removeAllListeners('preload'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we planning on adding more listeners? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for now - if we do it'll make sense to break it out into a separate function. |
||
} | ||
|
||
/** | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure images are not being created/repeated per locale.
It should be at a higher level so that all locales use the same image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like we discussed, this image is small and was already placed in the locale repos previously.