Skip to content

Commit

Permalink
Fix blurry SVG rendering in Firefox
Browse files Browse the repository at this point in the history
* use `object` elements instead of `img`s
  to display poster images.
* Current versions of Firefox render very large
  SVG images blurry when they are embedded
  as img elements. Embedding them as objects
  fixes this.
  • Loading branch information
fheft committed Jun 2, 2021
1 parent 56f7ffe commit 93e2560
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions js/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ export function notFound() {
return h("div", "Unwritten tale…");
}

function poster(url) {
return h("img.poster", {
attrs: { src: url },
function poster(url, type) {
return h("object.poster", {
attrs: { data: url, type },
});
}

Expand Down Expand Up @@ -239,7 +239,7 @@ let navigator = (tale, transformMatrix, cameraPosition, activeSlide) => {
},
},
[
poster(`/editor/${tale.slug}/${tale["file-path"]}`),
poster(`/editor/${tale.slug}/${tale["file-path"]}`, tale.fileType),
layer(
{
on: {
Expand Down
5 changes: 3 additions & 2 deletions js/presenter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export let presenter = tale => {
},
},
},
h("img", {
h("object", {
attrs: {
src: `/editor/${tale.slug}/${tale["file-path"]}`,
data: `/editor/${tale.slug}/${tale["file-path"]}`,
type: tale.fileType,
},
}),
),
Expand Down

0 comments on commit 93e2560

Please sign in to comment.