88 lines
3.9 KiB
JavaScript
Executable file
88 lines
3.9 KiB
JavaScript
Executable file
(function () {
|
|
var reveals = document.querySelectorAll('.reveal');
|
|
|
|
if ('IntersectionObserver' in window) {
|
|
var observer = new IntersectionObserver(function (entries) {
|
|
entries.forEach(function (entry) {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('is-visible');
|
|
observer.unobserve(entry.target);
|
|
}
|
|
});
|
|
}, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
|
|
|
|
reveals.forEach(function (el, i) {
|
|
if (el.closest('.cards') || el.closest('.faq')) {
|
|
el.style.setProperty('--delay', (i % 4) * 0.08 + 's');
|
|
}
|
|
observer.observe(el);
|
|
});
|
|
} else {
|
|
reveals.forEach(function (el) { el.classList.add('is-visible'); });
|
|
}
|
|
|
|
document.querySelectorAll('.card').forEach(function (card) {
|
|
card.addEventListener('pointermove', function (e) {
|
|
var rect = card.getBoundingClientRect();
|
|
card.style.setProperty('--mx', (e.clientX - rect.left) + 'px');
|
|
card.style.setProperty('--my', (e.clientY - rect.top) + 'px');
|
|
});
|
|
});
|
|
|
|
var chat = document.querySelector('.mock-chat');
|
|
if (chat) {
|
|
var names = ['Sam', 'Ruth', 'Kai', 'Milo', 'Jules', 'Bea', 'Ollie', 'Finn', 'Pip', 'Nora'];
|
|
var pool = [
|
|
"why did the scarecrow get promoted? he was outstanding in his field",
|
|
"I told my computer I needed a break and it said 'no problem, I'll go to sleep'",
|
|
"anyone else name their Wi-Fi something dramatic? mine is 'Pretty Fly for a Wi-Fi'",
|
|
"I'm reading a book on anti-gravity. it's impossible to put down",
|
|
"why don't eggs tell jokes? they'd crack each other up",
|
|
"just tried to catch fog. I mist",
|
|
"my dad said I should do lunges to stay in shape. that was a big step forward",
|
|
"what do you call a fake noodle? an impasta",
|
|
"I used to play piano by ear, but now I use my hands",
|
|
"why did the bicycle fall over? it was two-tired",
|
|
"I asked the dog for tech support. he just said 'ruff'",
|
|
"I'm on a seafood diet. I see food and I eat it",
|
|
"the rotation of the earth really makes my day",
|
|
"why can't you trust stairs? they're always up to something",
|
|
"I made a belt out of watches. it was a waist of time",
|
|
"did you hear about the claustrophobic astronaut? he just needed a little space",
|
|
"I would tell you a construction joke, but I'm still working on it",
|
|
"what do you call cheese that isn't yours? nacho cheese",
|
|
"my plants are thriving. I think they finally root for me",
|
|
"why did the math book look sad? it had too many problems",
|
|
"I got a job at a bakery because I kneaded dough",
|
|
"singing in the shower is fun until you get soap in your mouth. then it's a soap opera",
|
|
"I don't trust atoms. they make up everything",
|
|
"what did the ocean say to the beach? nothing, it just waved",
|
|
"I told a chemistry joke but there was no reaction",
|
|
"just burned 2000 calories. I forgot the pizza in the oven",
|
|
"why do cows have hooves instead of feet? because they lactose",
|
|
"I'm afraid for the calendar. its days are numbered",
|
|
"what do you call a bear with no teeth? a gummy bear",
|
|
"parallel lines have so much in common... it's a shame they'll never meet"
|
|
];
|
|
function pick(arr, n) {
|
|
var copy = arr.slice();
|
|
for (var i = copy.length - 1; i > 0; i--) {
|
|
var j = Math.floor(Math.random() * (i + 1));
|
|
var t = copy[i]; copy[i] = copy[j]; copy[j] = t;
|
|
}
|
|
return copy.slice(0, n);
|
|
}
|
|
var chosenNames = pick(names, 3);
|
|
var chosenMsgs = pick(pool, 3);
|
|
var avs = ['av-a', 'av-b', 'av-c'];
|
|
var html = '';
|
|
for (var k = 0; k < 3; k++) {
|
|
html += '<div class="msg msg-' + (k + 1) + '">' +
|
|
'<span class="av ' + avs[k] + '"></span>' +
|
|
'<div><b>' + chosenNames[k] + '</b><p>' + chosenMsgs[k] + '</p></div>' +
|
|
'</div>';
|
|
}
|
|
html += '<div class="typing"><span></span><span></span><span></span></div>';
|
|
chat.innerHTML = html;
|
|
}
|
|
})();
|