dom.addSection = (n) =>
{
+ let h = n.toLowerCase().replace(" ","-");
+
let e = document.createElement("div");
e.classList.add("section");
+ e.id = h;
dom.thumb_layer.appendChild(e);
+ let d = document.createElement("div");
+ d.classList.add("section-holder");
+ e.appendChild(d);
+
let t = document.createElement("div");
t.innerText = n;
t.classList.add("section-text");
- e.appendChild(t);
+ d.appendChild(t);
+
+ let u = document.createElement("ul");
+ u.classList.add("section-list");
+ u.id = h + "-list";
+ d.appendChild(u);
+ // 2em+1vh + n *
let g = document.createElement("div");
g.classList.add("grid");
dom.thumb_layer.appendChild(g);
dom.thumb_grid = g;
+ }
+ dom.finishSections = (l) =>
+ {
+ for (let section of document.getElementsByClassName("section-holder")) {
+ let height = section.offsetHeight;
+ let list = section.childNodes[1];
+ let name = section.childNodes[0].innerText;
+ for (let n of l) {
+ let h = n.toLowerCase().replace(" ","-");
+ let l = document.createElement("li");
+ list.appendChild(l);
+
+ let a = document.createElement("a");
+ a.innerText = n;
+ a.href = "#" + h;
+ l.appendChild(a);
+
+ if (n === name) {
+ console.log("Setting <" + n + "> top to: -" + height + "px");
+ list.style.top = "-" + height + "px";
+ }
+ height += a.offsetHeight;
+ }
+ }
}
dom.revealGrid = () => {
CLASS.show(dom.logo);
setTimeout(() => {
CLASS.show(dom.thumb_layer);
+ dom.scrollTo(window.location.hash);
}, 300);
}, 500);
}
+ dom.scrollTo = (hash) => {
+ if (hash) {
+ document.getElementById(hash.substring(1)).scrollIntoView();
+ }
+ }
+
dom.init = () => {
dom.logo = document.getElementById("logo");
dom.thumb_layer = document.getElementById("thumb-layer");
//// json handling ////
function loadJson(text) {
let json = JSON.parse(text);
+ let section_list = [];
let section = "";
PHOTO.all = json.photos;
PHOTO.all.forEach((p, i) => {
DOM.addThumbnail(p.thm)
} else {
section = p.date
+ section_list.push(p.date);
DOM.addSection(section);
DOM.addThumbnail(p.thm)
}
});
+ DOM.finishSections(section_list);
}
///// input handling /////
--gutter-width: calc(10px + 7vw);
}
+
body {
background-color: var(--bg-col);
color: var(--fg-col);
background-color: var(--bg-lite-col);
border-radius: 2vw;
padding: 1vw;
+ text-align: center;
+ visibility: visible;
+ opacity: 1;
+ transition: visibility 500ms, opacity 500ms;
+}
+
+.section-list {
+ background-color: var(--bg-lite-col);
+ border-radius: 2vw;
+ position: relative;
+ text-align: center;
+ list-style: none;
+ margin: 0;
+ padding: 1vw;
+ visibility: hidden;
+ opacity: 0;
+ transition: visibility 300ms, opacity 300ms;
+}
+
+.section-list a {
+ text-decoration: none;
+ color: var(--fg-col);
+ display: block;
+ padding: .3vw;
+}
+
+.section-holder {
+ height: calc(2em + 1vh);
+
+}
+
+.section-holder:hover .section-text {
+ visibility: hidden;
+ opacity: 0;
+ transition: visibility 300ms, opacity 300ms;
+}
+
+.section-holder:hover .section-list {
+ visibility: visible;
+ opacity: 1;
+ transition: visibility 500ms, opacity 500ms;
}
.grid {
.thumb > img {
border-radius: inherit;
- object-fit: cover;
min-width: 100%;
max-height: 200px;
transition: all 800ms ease-in-out;
/* these must remain at the bottom */
.parent { height: 95%; }
.fade-in {
- visibility: show;
opacity: 1;
transition: visibility 500ms, opacity 500ms;
}
opacity: 0;
transition: visibility 300ms, opacity 300ms;
}
-