Skip to content

Commit a125438

Browse files
committed
Switch opencollective image listing and avatars fadein
1 parent 1f11c77 commit a125438

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

docs/_includes/backers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
Find Mocha helpful? Become a [backer](https://opencollective.com/mochajs#support) and support Mocha with a monthly donation.
44

5-
{: id="_backers" }
5+
{: id="_backers" class="image-list" }
66
{% for i in (0..29) %}[![](//opencollective.com/mochajs/backer/{{ i }}/avatar.jpg)](https://opencollective.com/mochajs/backer/{{ i }}/website){: target="_blank" rel="noopener"}{% endfor %}

docs/_includes/head.html

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
<!--[if lt IE 9]>
1010
<script src="js/html5shiv.min.js"></script>
1111
<![endif]-->
12-
<script src="js/avatars.js"></script>
1312
</head>

docs/_includes/sponsors.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
Use Mocha at Work? Ask your manager or marketing team if they'd help [support](https://opencollective.com/mochajs#support) our project. Your company's logo will also be displayed on [npmjs.com](http://npmjs.com/package/mocha) and our [GitHub repository](https://github.com/mochajs/mocha#sponsors).
44

5-
{: id="_sponsors" }
6-
{% for i in (0..29) %}[![](//opencollective.com/mochajs/sponsor/{{ i }}/avatar.jpg){: onload="window.avatars.sponsorLoaded()" }](https://opencollective.com/mochajs/sponsor/{{ i }}/website){: target="_blank"} {% endfor %}
5+
{: class="image-list faded-images" }
6+
{% for i in (0..15) %}[![](//opencollective.com/mochajs/sponsor/{{ i }}/avatar.jpg)](https://opencollective.com/mochajs/sponsor/{{ i }}/website){: target="_blank"} {% endfor %}
7+
8+
<script src="js/avatars.js"></script>

docs/css/style.css

+12-17
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,32 @@ header {
5757
font-style: normal
5858
}
5959

60-
#_backers {
61-
display: flex;
62-
flex-wrap: wrap;
60+
.image-list {
61+
overflow: hidden;
6362
}
6463

65-
#_backers a {
66-
margin: 3px;
64+
.image-list a {
65+
float: left;
66+
margin: 6px;
6767
}
6868

69-
#_backers a img {
69+
.image-list a img {
7070
display: block;
71-
width: 64px;
7271
height: 64px;
73-
74-
margin: 0;
75-
box-shadow: none;
76-
77-
background: url(/images/backer-background.svg?inline) center center no-repeat;
7872
}
7973

80-
#_sponsors a {
74+
.faded-images img {
8175
opacity: 0;
8276
transition: opacity .3s;
8377
}
8478

85-
#_sponsors a img {
86-
max-height: 64px;
79+
.faded-images.is-loaded img {
80+
opacity: 1;
8781
}
8882

89-
#_sponsors.onload a {
90-
opacity: 1;
83+
#_backers a img {
84+
width: 64px;
85+
background: url(/images/backer-background.svg?inline) center center no-repeat;
9186
}
9287

9388
h2 {

docs/js/avatars.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
(function () {
22
'use strict';
3-
// dumb thing that helps with animation of avatars
4-
var avatars = window.avatars = function (type) {
5-
return function avatarLoaded () {
6-
avatars[type] = typeof avatars[type] === 'number' ? avatars[type] + 1 : 1;
7-
if (avatars[type] === 30) {
8-
document.getElementById(type).classList.add('onload');
3+
4+
var imageLists = document.querySelectorAll('.image-list');
5+
6+
Array.prototype.forEach.call(imageLists, function (imageList) {
7+
var images = imageList.querySelectorAll('img');
8+
var counter = images.length;
9+
10+
function onloadHandler() {
11+
counter -= 1;
12+
13+
if (counter === 0) {
14+
imageList.classList.add('is-loaded');
915
}
10-
};
11-
};
16+
}
17+
18+
for (var i = 0; i < images.length; i += 1) {
19+
images[i].onload = onloadHandler;
20+
}
21+
});
1222

13-
avatars.backerLoaded = avatars('_backers');
14-
avatars.sponsorLoaded = avatars('_sponsors');
1523
}());

0 commit comments

Comments
 (0)