Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull in contributors data at build time #9

Merged
merged 3 commits into from
Jun 20, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions layouts/partials/contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
#contributors-slide {
transform: translate3d(0,0,0); /* hint to prefer gpu rending. */
animation: slide 60s ease-in-out both 2s infinite alternate;
animation: slide 60s ease-in-out both 0s infinite alternate;
animation-play-state: paused;
}
#contributors-slide.running {
Expand All @@ -32,14 +32,12 @@
transform: scale(1.2);
z-index: 10;
}
#contributors .hex.show:hover + .hex {
}
#contributors .contributors-row {
height: 72px;
overflow:visible;
}
#contributors .contributors-row:hover {
z-index: 100;
z-index: 20;
}
</style>

Expand Down Expand Up @@ -75,15 +73,15 @@
var containerElTop = containerEl.getBoundingClientRect().top
var screenHeight = window.innerHeight
var pageYOffset = window.pageYOffset
var inView = (pageYOffset + screenHeight) > containerElTop
var inView = (pageYOffset + screenHeight + 100) > containerElTop
if (inView) {
renderContributors(contributors)
} else {
window.addEventListener('scroll', isContributorsSectionInView)
}

function isContributorsSectionInView () {
inView = (window.pageYOffset + screenHeight) > containerElTop
inView = (window.pageYOffset + screenHeight + 100) > containerElTop
if (inView) {
renderContributors(contributors)
window.removeEventListener('scroll', isContributorsSectionInView)
Expand All @@ -103,21 +101,24 @@
}
})
var nextRow = 0
function renderWithPause(itemIndex, lastRender) {
var lastRender = 0
function renderWithPause(itemIndex) {
if (itemIndex >= data.length) return
renderContributor(data[itemIndex], function (err, el) {
var nextIndex = itemIndex + 1
if (err) renderWithPause(nextIndex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this return renderWIthPause(/* ... */) here?

rows[nextRow].appendChild(el)
setTimeout(function () {
el.className = 'hex show'
}, 10)
nextIndex = itemIndex + 1
if (nextIndex === data.length) return // All done.
nextRow = (nextRow + 1) % rows.length
var now = Date.now()
var diff = now - lastRender
var delay = loadingDelayMs - diff
if (delay < 0) delay = 0
lastRender = now
nextRow = (nextRow + 1) % rows.length
setTimeout(function () {
renderWithPause(itemIndex + 1, now)
renderWithPause(itemIndex + 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use nextIndex?

}, delay)
})
}
Expand All @@ -139,6 +140,9 @@
link.style.backgroundSize = 'cover'
cb(null, link)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the image fails to load you halt the animation I think. You need an onerror handler to call the callback in this case.

img.onerror = function (evt) {
cb(evt, link)
}
img.src = item.photo
}
})()
Expand Down