Skip to content

Commit

Permalink
stick the fullscreen 320 back on there
Browse files Browse the repository at this point in the history
  • Loading branch information
knzai committed Aug 11, 2024
1 parent 9cac811 commit d926abf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/file_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ impl Raw {
}

pub fn previews(&self, parser: ParserType) -> Vec<Image> {
// if let Some(width) = width {
// }else {
self.widths(parser.image_type())
let mut previews = self
.widths(parser.image_type())
.iter()
.map(|w| Image(parser.process_input(&self.0, *w as usize)))
.collect()
// }
.map(|w| self.parse(parser, *w as usize))
.collect::<Vec<Image>>();
previews.push(self.parse(parser, 320));
previews
}
}
12 changes: 7 additions & 5 deletions src/wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
/>
<script data-trunk src="./file-byte-reader.js"></script>
<script>
let $ = (query, ele = document) => ele.querySelector(query);
const D = document;
const $ = (q, e = D) => e.querySelector(q);

function fileLoaded(array) {
let wrapper = $('preview-wrapper');
wrapper.textContent = "";

let parser_images = window.wasmBindings.previews(array);
for (const [key, images] of Object.entries(parser_images)) {
const container = document.createElement("preview-area");
const container = D.createElement("preview-area");
container.innerHTML = `<h3>${key}</h3>`
images.forEach(src => container.appendChild(new PreviewItem(src)));
wrapper.appendChild(container);
}
}

document.addEventListener("DOMContentLoaded", () => {
D.addEventListener("DOMContentLoaded", () => {
$('#file-input').addEventListener("file-byte-reader:loaded",
e => fileLoaded(e.detail)
);
Expand All @@ -35,7 +37,7 @@
constructor(src) {
super();
const shadow = this.attachShadow({mode: "open"});
const fragment = document.createRange().createContextualFragment('<h3></h3><img/>');
const fragment = D.createRange().createContextualFragment('<h3></h3><img/>');
const h3 = $('h3', fragment);
this.img = $('img', fragment);

Expand Down

0 comments on commit d926abf

Please sign in to comment.