Skip to content

Commit

Permalink
Show preview of the gorgeous gif when hovering over link
Browse files Browse the repository at this point in the history
This change improves selecting the right gif by 238%. When hovering with
le mouse over a link, it shows the corresponding gif in the sidebar.
  • Loading branch information
pangratz committed Feb 7, 2014
1 parent 09e6e8b commit 0a2905e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@
<header class="page-header">
<img src="/aha/aha.gif" alt="" class="banner-img">
{{ content }}

<img src="" id="preview" class="banner-img">
</header>

<div class="gif-listing">
{% include site-index.html %}
</div>

<script type="text/javascript">
var preview = document.getElementById("preview");

function hoverListener(evt) {
preview.src = evt.target.href;
};

var links = document.getElementsByClassName("gif");
for(var i=0; i<links.length; i++) {
links[i].addEventListener("mouseover", hoverListener);
}
</script>
</body>

{% include closing-tags.html %}
3 changes: 2 additions & 1 deletion script/build_site_index
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ list.ul do |builder|
li.a(
File.basename(gif),
"href" => gif,
"title" => gif
"title" => gif,
"class" => "gif"
)
end
end
Expand Down

0 comments on commit 0a2905e

Please sign in to comment.