rework CSS and JS
This commit is contained in:
@@ -18,123 +18,170 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The Modal (background) */
|
.snap-lightbox {
|
||||||
.modal {
|
/** Default lightbox to hidden */
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
|
/** Position and style */
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 1;
|
z-index: 999;
|
||||||
padding-top: 50px;
|
|
||||||
//padding-bottom: 10%;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;;
|
height: 100%;
|
||||||
overflow: auto;
|
text-align: center;
|
||||||
background-color: black;
|
white-space: nowrap;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.8);
|
||||||
|
|
||||||
|
/* keep lightbox in middle. TODO: hacky, and not realibly in middle */
|
||||||
|
&:before {
|
||||||
|
content: "";
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
width: 0;
|
||||||
|
/* adjust for white space between pseudo element and next sibling */
|
||||||
|
margin-right: -.25em;
|
||||||
|
/* stretch line height */
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modal Content */
|
// /* Click on the complete background closes the lightbox */
|
||||||
.modal-content {
|
// /* Exception: arrow in gallery, they have higher z-index */
|
||||||
position: relative;
|
// a.snap-lightbox-close {
|
||||||
background-color: #fefefe;
|
// position: fixed;
|
||||||
margin: auto;
|
// z-index: 800;
|
||||||
padding: 0;
|
// width: 100%;
|
||||||
width: 90%;
|
// height: 100%;
|
||||||
max-width: 1200px;
|
// text-align: center;
|
||||||
height: calc(100% - 100px);
|
// white-space: nowrap;
|
||||||
}
|
// top: 0;
|
||||||
|
// left: 0;
|
||||||
|
// }
|
||||||
|
|
||||||
/* The Close Button */
|
/* Container for image */
|
||||||
.close {
|
.snap-lightbox-inner {
|
||||||
color: white;
|
display: inline-block;
|
||||||
position: absolute;
|
vertical-align: middle;
|
||||||
top: 10px;
|
white-space: normal;
|
||||||
right: 25px;
|
max-width: 90%;
|
||||||
font-size: 35px;
|
max-height: 80%;
|
||||||
font-weight: bold;
|
height: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.close:hover,
|
/* Number text (1/3 etc) */
|
||||||
.close:focus {
|
.numbertext {
|
||||||
color: #999;
|
color: #f2f2f2;
|
||||||
text-decoration: none;
|
background-color: #000;
|
||||||
cursor: pointer;
|
font-size: 12px;
|
||||||
}
|
padding: 8px 12px;
|
||||||
|
position: absolute;
|
||||||
/* Hide the slides by default */
|
top: 10%;
|
||||||
.snap-slide {
|
}
|
||||||
display: none;
|
|
||||||
|
|
||||||
max-height: 100%;
|
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Untested
|
||||||
|
p {
|
||||||
|
color: #fff;
|
||||||
|
z-index: 810;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next & previous buttons */
|
// /* Caption text */
|
||||||
.prev,
|
// .caption-container {
|
||||||
.next {
|
// text-align: center;
|
||||||
cursor: pointer;
|
// background-color: black;
|
||||||
position: absolute;
|
// padding: 2px 16px;
|
||||||
top: 50%;
|
// color: white;
|
||||||
width: auto;
|
// }
|
||||||
padding: 16px;
|
|
||||||
margin-top: -50px;
|
|
||||||
color: white;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 20px;
|
|
||||||
transition: 0.6s ease;
|
|
||||||
border-radius: 0 3px 3px 0;
|
|
||||||
user-select: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
text-decoration: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Position the "next button" to the right */
|
/* prev/next arrows & close button */
|
||||||
.next {
|
.snap-lightbox-prev,
|
||||||
right: 0;
|
.snap-lightbox-next {
|
||||||
border-radius: 3px 0 0 3px;
|
position: fixed;
|
||||||
}
|
z-index: 800;
|
||||||
|
width: 5%;
|
||||||
/* On hover, add a black background color with a little bit see-through */
|
height: 100%;
|
||||||
.prev:hover,
|
|
||||||
.next:hover {
|
|
||||||
background-color: rgba(0, 0, 0, 0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Number text (1/3 etc) */
|
|
||||||
.numbertext {
|
|
||||||
color: #f2f2f2;
|
|
||||||
background-color: #000;
|
|
||||||
font-size: 12px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Caption text */
|
|
||||||
.caption-container {
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: black;
|
top: 0;
|
||||||
padding: 2px 16px;
|
|
||||||
|
.snap-lightbox-arrow {
|
||||||
|
display: inline-block;
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
z-index: 900;
|
||||||
|
border: solid #fff;
|
||||||
|
border-width: 0 7px 7px 0;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 1%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover>.snap-lightbox-arrow {
|
||||||
|
border-color: #999;
|
||||||
|
transition: all 0.25s ease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.snap-lightbox-prev {
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
.snap-lightbox-arrow {
|
||||||
|
left: 2%;
|
||||||
|
transform: rotate(135deg);
|
||||||
|
-webkit-transform: rotate(135deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.snap-lightbox-next {
|
||||||
|
right: 0;
|
||||||
|
|
||||||
|
.snap-lightbox-arrow {
|
||||||
|
right: 2%;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
-webkit-transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The Close Button */
|
||||||
|
.snap-close {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 15px;
|
||||||
|
right: 15px;
|
||||||
|
height: 50px;
|
||||||
|
width: 50px;
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 50px;
|
||||||
|
font-weight: bold;
|
||||||
|
z-index: 900;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
color: #999;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img.img-thumb {
|
@media screen and (max-width: 767px) {
|
||||||
opacity: 0.6;
|
.snap-lightbox-inner {
|
||||||
}
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
.img-active,
|
.snap-lightbox-prev,
|
||||||
.img-thumb:hover {
|
.snap-lightbox-next {
|
||||||
opacity: 1 !important;
|
width: 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.hover-shadow {
|
.snap-lightbox-close-button {
|
||||||
transition: 0.3s;
|
width: 10%;
|
||||||
}
|
height: calc(10vw);
|
||||||
|
/* ~10% width */
|
||||||
.hover-shadow:hover {
|
}
|
||||||
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
{{- with resources.Get "scss/snap-gallery.scss" | toCSS }}
|
{{- with resources.Get "scss/snap-gallery.scss" | toCSS }}
|
||||||
<link rel="stylesheet" href="{{ .RelPermalink }}" crossorigin="anonymous">
|
<link rel="stylesheet" href="{{ .RelPermalink }}" crossorigin="anonymous">
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<script src="/js/snap-gallery.js"></script>
|
|
||||||
|
|
||||||
{{/* Initialise variables */}}
|
{{/* Initialise variables */}}
|
||||||
{{ $imgs := slice }}
|
{{ $imgs := slice }}
|
||||||
@@ -31,31 +30,26 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{/* The Modal/Lightbox */}}
|
{{/* The Modal/Lightbox */}}
|
||||||
<div id="snap-modal" class="modal">
|
<div class="snap-lightbox">
|
||||||
<span class="close cursor" onclick="closeModal()">×</span>
|
{{ range $i, $img := $imgs }}
|
||||||
<div class="modal-content">
|
<div class="snap-lightbox-inner">
|
||||||
|
<div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
|
||||||
{{ range $i, $img := $imgs }}
|
<img src="{{ $img }}" style="width:100%">
|
||||||
<div class="snap-slide">
|
|
||||||
<div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
|
|
||||||
<img src="{{ $img }}" style="width:100%">
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<!-- Next/previous controls -->
|
|
||||||
<a class="prev" onclick="plusSlides(-1)">❮</a>
|
|
||||||
<a class="next" onclick="plusSlides(1)">❯</a>
|
|
||||||
|
|
||||||
<!-- Caption text -->
|
|
||||||
<div class="caption-container">
|
|
||||||
<p id="caption"></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Thumbnail image controls -->
|
|
||||||
{{/* {{ range $i, $img := $imgs }}
|
|
||||||
<div class="snap-image">
|
|
||||||
<img class="img-thumb" src="{{ $img }}" onclick="currentSlide({{ add $i 1 }})" alt="Nature">
|
|
||||||
</div>
|
|
||||||
{{ end }} */}}
|
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<!-- Close and Next/previous controls -->
|
||||||
|
<span class="snap-close" onclick="closeModal()">×</span>
|
||||||
|
|
||||||
|
<a class="snap-lightbox-prev" onclick="plusSlides(-1)"><i class="snap-lightbox-arrow"></i></a>
|
||||||
|
<a class="snap-lightbox-next" onclick="plusSlides(1)"><i class="snap-lightbox-arrow"></i></a>
|
||||||
|
{{/* <a class="prev" onclick="plusSlides(-1)">❮</a>
|
||||||
|
<a class="next" onclick="plusSlides(1)">❯</a> */}}
|
||||||
|
|
||||||
|
{{/* <!-- Caption text -->
|
||||||
|
<div class="caption-container">
|
||||||
|
<p id="caption"></p>
|
||||||
|
</div> */}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/snap-gallery.js"></script>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// Open the Modal
|
// Open the Modal
|
||||||
function openModal() {
|
function openModal() {
|
||||||
document.getElementById("snap-modal").style.display = "block";
|
document.getElementsByClassName("snap-lightbox")[0].style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the Modal
|
// Close the Modal
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
document.getElementById("snap-modal").style.display = "none";
|
document.getElementsByClassName("snap-lightbox")[0].style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
var slideIndex = 1;
|
var slideIndex = 1;
|
||||||
@@ -23,18 +23,11 @@ function currentSlide(n) {
|
|||||||
|
|
||||||
function showSlides(n) {
|
function showSlides(n) {
|
||||||
var i;
|
var i;
|
||||||
var slides = document.getElementsByClassName("snap-slide");
|
var slides = document.getElementsByClassName("snap-lightbox-inner");
|
||||||
var dots = document.getElementsByClassName("img-thumb");
|
|
||||||
var captionText = document.getElementById("caption");
|
|
||||||
if (n > slides.length) { slideIndex = 1 }
|
if (n > slides.length) { slideIndex = 1 }
|
||||||
if (n < 1) { slideIndex = slides.length }
|
if (n < 1) { slideIndex = slides.length }
|
||||||
for (i = 0; i < slides.length; i++) {
|
for (i = 0; i < slides.length; i++) {
|
||||||
slides[i].style.display = "none";
|
slides[i].style.display = "none";
|
||||||
}
|
}
|
||||||
for (i = 0; i < dots.length; i++) {
|
|
||||||
dots[i].className = dots[i].className.replace(" img-active", "");
|
|
||||||
}
|
|
||||||
slides[slideIndex - 1].style.display = "inline-block";
|
slides[slideIndex - 1].style.display = "inline-block";
|
||||||
dots[slideIndex - 1].className += " img-active";
|
|
||||||
captionText.innerHTML = dots[slideIndex - 1].alt;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user