cb61bdee34
Having thought *briefly* about using `css-vars-ponyfill`, I'm no longer convinced that it'd be a good idea. The reason is that if we actually want to properly support CSS variables, then that functionality should be available in *all* of our CSS files. Note in particular the `pdf_viewer.css` file that's built as part of the `COMPONENTS` target, in which case I really cannot see how a rewrite-at-the-client solution would ever be guaranteed to always work correctly and without accidentally touching other CSS in the surrounding application. All-in-all, simply re-writing the CSS variables at build-time seems much easier and is thus the approach taken in this patch; courtesy of https://github.com/MadLittleMods/postcss-css-variables By using its `preserve` option, the built files will thus include *both* a fallback and a modern `var(...)` format[1]. As a proof-of-concept this patch removes a couple of manually added fallback values, and converts an additional sidebar related property to use a CSS variable. --- [1] Comparing the `master` branch with this patch, when using `gulp generic`, produces the following diff for the built `web/viewer.css` file: ```diff @@ -408,6 +408,7 @@ :root { --sidebar-width: 200px; + --sidebar-transition-duration: 200ms; } * { @@ -550,27 +551,28 @@ position: absolute; top: 32px; bottom: 0; - width: 200px; /* Here, and elsewhere below, keep the constant value for compatibility - with older browsers that lack support for CSS variables. */ + width: 200px; width: var(--sidebar-width); visibility: hidden; z-index: 100; border-top: 1px solid rgba(51, 51, 51, 1); -webkit-transition-duration: 200ms; transition-duration: 200ms; + -webkit-transition-duration: var(--sidebar-transition-duration); + transition-duration: var(--sidebar-transition-duration); -webkit-transition-timing-function: ease; transition-timing-function: ease; } html[dir='ltr'] #sidebarContainer { -webkit-transition-property: left; transition-property: left; - left: -200px; + left: calc(-1 * 200px); left: calc(-1 * var(--sidebar-width)); } html[dir='rtl'] #sidebarContainer { -webkit-transition-property: right; transition-property: right; - right: -200px; + right: calc(-1 * 200px); right: calc(-1 * var(--sidebar-width)); } @@ -640,6 +642,8 @@ #viewerContainer:not(.pdfPresentationMode) { -webkit-transition-duration: 200ms; transition-duration: 200ms; + -webkit-transition-duration: var(--sidebar-transition-duration); + transition-duration: var(--sidebar-transition-duration); -webkit-transition-timing-function: ease; transition-timing-function: ease; } ``` |
||
---|---|---|
.. | ||
images | ||
.eslintrc | ||
.gitignore | ||
annotation_layer_builder.css | ||
annotation_layer_builder.js | ||
app_options.js | ||
app.js | ||
base_viewer.js | ||
chrome-i18n-allow-access-to-file-urls.json | ||
chromecom.js | ||
compressed.tracemonkey-pldi-09.pdf | ||
debugger.js | ||
download_manager.js | ||
firefox_print_service.js | ||
firefoxcom.js | ||
genericcom.js | ||
genericl10n.js | ||
grab_to_pan.js | ||
interfaces.js | ||
overlay_manager.js | ||
password_prompt.js | ||
pdf_attachment_viewer.js | ||
pdf_cursor_tools.js | ||
pdf_document_properties.js | ||
pdf_find_bar.js | ||
pdf_find_controller.js | ||
pdf_find_utils.js | ||
pdf_history.js | ||
pdf_link_service.js | ||
pdf_outline_viewer.js | ||
pdf_page_view.js | ||
pdf_presentation_mode.js | ||
pdf_print_service.js | ||
pdf_rendering_queue.js | ||
pdf_sidebar_resizer.js | ||
pdf_sidebar.js | ||
pdf_single_page_viewer.js | ||
pdf_thumbnail_view.js | ||
pdf_thumbnail_viewer.js | ||
pdf_viewer.component.js | ||
pdf_viewer.css | ||
pdf_viewer.js | ||
pdfjs.js | ||
preferences.js | ||
secondary_toolbar.js | ||
text_layer_builder.css | ||
text_layer_builder.js | ||
toolbar.js | ||
ui_utils.js | ||
view_history.js | ||
viewer_compatibility.js | ||
viewer-snippet-chrome-extension.html | ||
viewer-snippet-chrome-overlays.html | ||
viewer-snippet-firefox-extension.html | ||
viewer-snippet-minified.html | ||
viewer-snippet.html | ||
viewer.css | ||
viewer.html | ||
viewer.js |