Skip to content

Commit

Permalink
Add a zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianvasquez committed Dec 27, 2024
1 parent 5bbf2e1 commit 45d8fa2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
<style>
#images {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
padding: 20px;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px;
padding: 10px;
}

.image-container {
position: relative;
min-height: 200px;
/*width: 200px; !* Default width *!*/
border: 1px solid #ccc;
padding: 10px;
display: flex;
Expand All @@ -27,6 +28,8 @@
.image-container img {
max-width: 100%;
height: auto;
http: / /
localhost: 5173/
}

.loading {
Expand All @@ -45,8 +48,9 @@
<h1>Display a Supernote File</h1>
<form id="uploadForm">
<input type="file" id="noteInput" accept=".note" required/>
<label for="widthSlider">width </label>
<input type="range" id="widthSlider" min="150" max="1600">
</form>
<progress id="progressBar" value="0" max="100" style="display: none;"></progress>
<div id="images"></div>

<script type="module">
Expand All @@ -72,7 +76,8 @@ <h1>Display a Supernote File</h1>
}
}

const MAX_WORKERS = 3
const hardwareConcurrency = navigator.hardwareConcurrency || 3 // Default to 1 if not available
const MAX_WORKERS = Math.min(hardwareConcurrency, 8)

document.getElementById('noteInput').addEventListener('change', async (event) => {
const file = event.target.files[0]
Expand Down Expand Up @@ -111,6 +116,16 @@ <h1>Display a Supernote File</h1>
if (pageIndex) worker.process(note, pageIndex)
})
})

document.getElementById('widthSlider').addEventListener('input', (event) => {
const width = event.target.value + 'px'
document.querySelectorAll('.image-container').forEach(container => {
container.style.width = width
})
document.getElementById('images').style.gridTemplateColumns = `repeat(auto-fit, minmax(${width}, 1fr))`
})


</script>


Expand Down

0 comments on commit 45d8fa2

Please sign in to comment.