Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commitbc5188fc21a825f4849139cd9888b0476fd34a99 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-02-20 13:09:15 +0200
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-02-20 13:09:15 +0200
Files067f96fc807cab3269d54fa4874ba79292912e3b /src
syndamia.com-bc5188fc21a825f4849139cd9888b0476fd34a99.tar
syndamia.com-bc5188fc21a825f4849139cd9888b0476fd34a99.tar.gz
syndamia.com-bc5188fc21a825f4849139cd9888b0476fd34a99.zip
Parentd00c9b47607d57512ebe90ce0ce98bdb3834dd9c (diff)
Implemented click to zoom on images
3 files changed, 45 insertions, 4 deletions
-rw-r--r--src/_footer.html2
-rw-r--r--src/scripts/image-show.js24
-rw-r--r--src/styles.css23
diff --git a/src/_footer.html b/src/_footer.html
index 32da16f..b498d55 100644
--- a/src/_footer.html
+++ b/src/_footer.html
@@ -18,6 +18,8 @@
<a href="https://www.romanzolotarev.com/ssg.html" target="_blank" class="link-tab">ssg by Roman Zolotarev</a>
<a href="https://kristaps.bsd.lv/lowdown/" target="_blank" class="link-tab">lowdown by Kristaps Dzonsons</a>
</nav>
+
+ <script type="text/javascript" src="/scripts/image-show.js"></script>
</body>
</html>
diff --git a/src/scripts/image-show.js b/src/scripts/image-show.js
new file mode 100644
index 0000000..1683107
--- /dev/null
+++ b/src/scripts/image-show.js
@@ -0,0 +1,24 @@
+let scrollPosition = 0;
+
+function clickToView() {
+ if (scrollPosition === 0) {
+ scrollPosition = window.scrollY;
+ window.scrollTo(0, 0);
+ }
+
+ this.classList.toggle('clicked-image');
+ document.body.classList.toggle('body-on-clicked-image');
+
+ if (this.className.length === 0) {
+ window.scrollTo(0, scrollPosition);
+ scrollPosition = 0;
+ }
+}
+
+const images = document.getElementsByTagName('img');
+
+for (const image of images) {
+ if (image.alt !== '🔗') {
+ image.onclick = clickToView;
+ }
+}
diff --git a/src/styles.css b/src/styles.css
index 5ecf230..abe7006 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -58,10 +58,6 @@ img {
image-rendering: crisp-edges;
}
-img:hover {
- image-rendering: pixelated;
-}
-
img, hr {
border: 1px solid black;
}
@@ -360,6 +356,25 @@ code span {
color: #afaf00;
}
+/* Script specific styling */
+
+.clicked-image {
+ position: absolute;
+ width: 100vw;
+ height: 100vh;
+ max-width: none !important;
+ max-height: none !important;
+ border: none;
+ object-fit: contain;
+ left: 0;
+ top: 0;
+ padding: 1em;
+}
+
+.body-on-clicked-image {
+ overflow: hidden;
+}
+
/* OpenSans font */
@font-face {