-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathindex.html
93 lines (87 loc) · 3.02 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
layout: default
title: Home
---
<h2 class="section-title">Featured</h2>
<div class="featured-posts">
<a href="#" id="goPrev" class="featured-posts-goprev"></a>
<div class="featured-posts-container">
<ul class="posts list-unstyled">
{% for post in site.categories.featured %}
<li>
{% assign item = post %}
{% include screenshot.html %}
</a>
<div class="post-description">
<h3 class="post-description-title"><a href="{{ post.url }}" class="post-description-link">{{ post.title }}</a></h3>
<p class="post-description-date">{{ post.date | date: "%B %-d, %Y" }}</p>
</div>
</li>
{% endfor %}
</ul>
</div>
<a href="#" id="goNext" class="featured-posts-gonext visible"></a>
</div>
<div id="home">
<h2 class="section-title">Recent</h2>
<ul class="posts list-unstyled">
{% for post in paginator.posts %}
<li>
{% assign item = post %}
{% include screenshot.html %}
</a>
<div class="post-description">
<h3 class="post-description-title"><a href="{{ post.url }}" class="post-description-link">{{ post.title }}</a></h3>
<p class="post-description-date">{{ post.date | date: "%B %-d, %Y" }}</p>
</div>
</li>
{% endfor %}
</ul>
{% include pagination.html %}
</div>
<script>
$(function () {
var $goPrev = $('#goPrev'),
$goNext = $('#goNext'),
$featuredContainer = $('.featured-posts-container'),
scrollDuration = 400,
scrollDistance = '480',
itemMargin = 15,
totalItemsCount = $featuredContainer.find('li').length,
totalItemsWidth = ($featuredContainer.find('li:first').outerWidth() + itemMargin) * totalItemsCount,
hasScrollReachedTheStart = function () {
return $featuredContainer.scrollLeft() === 0;
},
hasScrollReachedTheEnd = function () {
return $featuredContainer.scrollLeft() === totalItemsWidth - $featuredContainer.outerWidth() - 5;
};
// on click logic
// moves the scroll bar after clicking on the arrows
$goPrev.on('click', function () {
$featuredContainer.animate({scrollLeft: '-='+scrollDistance}, scrollDuration);
return false;
});
$goNext.on('click', function () {
$featuredContainer.animate({scrollLeft: '+='+scrollDistance}, scrollDuration);
return false;
});
// on scroll logic
// handles hiding and showing of the arrows
// waits for the end of scrolling
$featuredContainer.scroll(function () {
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function () {
if (hasScrollReachedTheStart()) {
$goPrev.removeClass('visible');
$goNext.addClass('visible');
} else if (hasScrollReachedTheEnd()) {
$goNext.removeClass('visible');
$goPrev.addClass('visible');
} else {
$goPrev.addClass('visible');
$goNext.addClass('visible');
}
}, 250));
});
});
</script>