Add image zoom JS

This commit is contained in:
Ariejan de Vroom 2016-10-10 15:53:46 +02:00
parent fb80774034
commit 026ada70c9
Signed by: ariejan
GPG Key ID: AD739154F713697B
2 changed files with 31 additions and 0 deletions

View File

@ -34,4 +34,21 @@
{{ end }}
</article>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(document).on('click', 'article img', function() {
$(this).toggleClass('zoomed');
});
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('img.zoomed').each(function(idx) {
$(this).toggleClass('zoomed');
});
}
});
});
</script>
{{ partial "footer.html" . }}

View File

@ -193,6 +193,20 @@ article img {
max-width: 100%;
}
article img.zoomed {
position: fixed;
top: 5vh;
bottom: 5vh;
left: 5vw;
right: 5vw;
max-width: 90vw;
max-height: 90vh;
margin: auto;
}
img.img-right {
margin: 0 2em;
width: 33%;