Skip to content

Commit

Permalink
Load random background img for hompage
Browse files Browse the repository at this point in the history
Issue #27
  • Loading branch information
CodeWritingCow committed Apr 11, 2018
1 parent 40accf7 commit 621924f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions views/home.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<div class="parallax-container hide-on-small-only valign-wrapper">
<div class="parallax">
<img src="/public/assets/img/michael-browning-14090-unsplash-1024x683.jpg" alt="Men working in kitchen. Photo by Michael Browning on Unsplash." class="black-white">
<img id="parallaxImg" src="/public/assets/img/michael-browning-14090-unsplash-1024x683.jpg" alt="Men working in kitchen. Photo by Michael Browning on Unsplash.">
</div>
{{> searchFormParallax}}
</div>
Expand Down Expand Up @@ -80,6 +80,18 @@
$('select').material_select();
$(".button-collapse").sideNav();
$('.parallax').parallax();
});
});
const imgCount = 6;
const dir = '/public/assets/img/';
const randomCount = Math.round(Math.random() * (imgCount - 1)) + 1;
const images = new Array;
images[1] = "michael-browning-14090-unsplash-1024x683.jpg";
images[2] = "michael-browning-14092-unsplash-1024x683.jpg";
images[3] = "joanna-boj-17158-unsplash-1024x683.jpg";
images[4] = "making-waffles-cutting-them-into-pieces-picjumbo-com-1024x683.jpg";
images[5] = "clem-onojeghuo-97089-unsplash-1024x683.jpg";
images[6] = "woman-holding-an-ice-cream-picjumbo-com-1024x683.jpg";
const randomImg = dir + images[randomCount]
document.getElementById("parallaxImg").src=randomImg;
</script>
</html>

0 comments on commit 621924f

Please sign in to comment.