mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Replace viewport units in CSS
In theory it could do something much more complicated. But it seems better to just say "vh and vw are not supported", and this would just be failing more gracefully. I mean, the spec itself says, > Keep in mind that some Reading Systems will not support all desired > features of CSS. In particular, the following are known to be > problematic [...] Pagination is sometimes done using columns, which > can result in incorrect values for viewport sizes. Fixes #1
This commit is contained in:
@@ -530,7 +530,12 @@ class Loader {
|
||||
/@import\s*["']([^"'\n]*?)["']/gi,
|
||||
(_, url) => this.loadHref(url, href, parents)
|
||||
.then(url => `@import "${url}"`))
|
||||
return replacedImports.replaceAll('-epub-', '')
|
||||
const w = window?.innerWidth ?? 800
|
||||
const h = window?.innerHeight ?? 600
|
||||
const replacedVwVh = replacedImports
|
||||
.replace(/(\d*\.?\d+)vw/g, (_, d) => parseFloat(d) * w / 100 + 'px')
|
||||
.replace(/(\d*\.?\d+)vh/g, (_, d) => parseFloat(d) * h / 100 + 'px')
|
||||
return replacedVwVh.replaceAll('-epub-', '')
|
||||
}
|
||||
// find & replace all possible relative paths for all assets without parsing
|
||||
replaceString(str, href, parents = []) {
|
||||
|
||||
Reference in New Issue
Block a user