CHANGE scroll indicators to be interactive

This commit is contained in:
Hoernschen 2024-06-20 12:36:59 +02:00
parent 559cf1ef80
commit aee652e045
Signed by: hoernschen
GPG key ID: 37591FAF4E6D3462
4 changed files with 45 additions and 24 deletions

View file

@ -0,0 +1,11 @@
function scrollDown() {
var scroller = document.getElementById("scroller");
var height = scroller.offsetHeight;
scroller.scrollBy(0, height);
}
function scrollUp() {
var scroller = document.getElementById("scroller");
var height = scroller.offsetHeight;
scroller.scrollBy(0, -1 * height);
}

View file

@ -153,9 +153,21 @@ header {
justify-content: center; justify-content: center;
position: relative; position: relative;
width: 100%; width: 100%;
bottom: 0;
padding: 2rem; padding: 2rem;
font-size: x-large; font-size: x-large;
.down {
bottom: 0;
}
.up {
top: 0;
}
i {
color: {{ .Site.Params.color.secondary }};
cursor: pointer;
}
} }
.totop { .totop {
@ -297,6 +309,14 @@ header {
} }
} }
} }
:last-child {
.scroll-indicator.down {
display: none;
}
}
} }
article { article {

View file

@ -1,5 +1,5 @@
{{ define "main" }} {{ define "main" }}
<div class="scroller"> <div id="scroller" class="scroller">
<section> <section>
<div class="profile card"> <div class="profile card">
{{ if .Params.image }} {{ if .Params.image }}
@ -21,14 +21,15 @@
{{ end }} {{ end }}
</div> </div>
</div> </div>
<div class="scroll-indicator"> <div class="scroll-indicator down">
<a href="#"> <i class="icon-angle-down" onclick="scrollDown()"></i>
<i class="icon-angle-down"></i>
</a>
</div> </div>
</section> </section>
{{ range where .Site.RegularPages "Section" "projects"}} {{ range where .Site.RegularPages "Section" "projects"}}
<section> <section>
<div class="scroll-indicator up">
<i class="icon-angle-up" onclick="scrollUp()"></i>
</div>
<div class="card"> <div class="card">
{{ if .Params.image }} {{ if .Params.image }}
<div class="image"> <div class="image">
@ -49,10 +50,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="scroll-indicator"> <div class="scroll-indicator down">
<a href="#"> <i class="icon-angle-down" onclick="scrollDown()"></i>
<i class="icon-angle-down"></i>
</a>
</div> </div>
</section> </section>
{{ end }} {{ end }}

View file

@ -1,12 +1,3 @@
{{- with resources.Get "js/main.js" }} {{- with resources.Get "js/main.js" | minify | fingerprint }}
{{- if eq hugo.Environment "development" }}
{{- with . | js.Build }}
<script src="{{ .RelPermalink }}"></script>
{{- end }}
{{- else }}
{{- $opts := dict "minify" true }}
{{- with . | js.Build $opts | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script> <script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
{{- end }} {{- end }}
{{- end }}
{{- end }}