Merge pull request #16915 from overleaf/tm-website-redesign-animation-a11y

Website redesign - update animation accessibility and tweak animation to match design spec

GitOrigin-RevId: 21b69f3d8b2ab8bafd9c31db19a7f2a365e2c039
This commit is contained in:
M Fahru 2024-02-08 07:12:22 -07:00 committed by Copybot
parent dc8d01cd74
commit 01e551e606

View file

@ -27,9 +27,11 @@ function realTimeEditsDemo() {
nextFrame() nextFrame()
} }
if (document.querySelector('.real-time-example')) {
realTimeEditsDemo() realTimeEditsDemo()
}
function homepageAnimation() { function homepageAnimation(homepageAnimationEl) {
function createFrames(word, { buildTime, holdTime, breakTime }) { function createFrames(word, { buildTime, holdTime, breakTime }) {
const frames = [] const frames = []
let current = '' let current = ''
@ -50,7 +52,7 @@ function homepageAnimation() {
} }
// Add the final frame with an empty string // Add the final frame with an empty string
frames.push({ before: '', time: holdTime }) frames.push({ before: '', time: breakTime })
return frames return frames
} }
@ -62,11 +64,14 @@ function homepageAnimation() {
} }
const frames = [ const frames = [
// 1.5s pause before starting
{ before: '', time: 1500 },
...createFrames('articles', opts), ...createFrames('articles', opts),
...createFrames('theses', opts), ...createFrames('theses', opts),
...createFrames('reports', opts), ...createFrames('reports', opts),
...createFrames('presentations', opts), ...createFrames('presentations', opts),
...createFrames('anything', opts), // 5s pause on 'anything' frame
...createFrames('anything', { ...opts, holdTime: 5000 }),
] ]
let index = 0 let index = 0
@ -74,10 +79,22 @@ function homepageAnimation() {
const frame = frames[index] const frame = frames[index]
index = (index + 1) % frames.length index = (index + 1) % frames.length
$('#home-animation-text').html(frame.before) homepageAnimationEl.innerHTML = frame.before
setTimeout(nextFrame, frame.time) setTimeout(nextFrame, frame.time)
} }
nextFrame() nextFrame()
} }
homepageAnimation()
const homepageAnimationEl = document.querySelector('#home-animation-text')
const reducedMotionReduce = window.matchMedia(
'(prefers-reduced-motion: reduce)'
)
if (homepageAnimationEl) {
if (reducedMotionReduce.matches) {
homepageAnimationEl.innerHTML = 'anything'
} else {
homepageAnimation(homepageAnimationEl)
}
}