|
|
|
@ -35,11 +35,33 @@ document.addEventListener('turbo:render', (event) => { |
|
|
|
|
|
|
|
// document.addEventListener("turbo:before-stream-render", animateElements)
|
|
|
|
document.addEventListener("turbo:load", animateElements) |
|
|
|
document.addEventListener("turbo:load", validateFormInput) |
|
|
|
|
|
|
|
|
|
|
|
function validateFormInput(event) { |
|
|
|
const form = document.getElementById('questionForm'); |
|
|
|
const submitBtn = document.getElementById('questionSubmitButton'); |
|
|
|
|
|
|
|
form.addEventListener('submit', e => { |
|
|
|
// If no radio in the group is checked…
|
|
|
|
if (!form.querySelector('input[type=radio]:checked')) { |
|
|
|
e.preventDefault(); // stop the form from submitting
|
|
|
|
submitBtn.classList.remove('wiggle'); // reset so the animation can retrigger
|
|
|
|
void submitBtn.offsetWidth; // force reflow (quick trick)
|
|
|
|
submitBtn.classList.add('wiggle'); // start the wiggle
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// Tidy up the class once the animation ends
|
|
|
|
submitBtn.addEventListener('animationend', () => { |
|
|
|
submitBtn.classList.remove('wiggle'); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function animateElements(event) { |
|
|
|
|
|
|
|
console.info(event.type) |
|
|
|
// console.info(event.type)
|
|
|
|
|
|
|
|
// Copy link to clipboard
|
|
|
|
document.querySelectorAll('[data-share-title]').forEach((share_btn) => { |
|
|
|
@ -72,8 +94,7 @@ function animateElements(event) { |
|
|
|
|
|
|
|
gsap.set(animationElements, { |
|
|
|
height: 0, |
|
|
|
opacity: 0, |
|
|
|
overflow: 'hidden' |
|
|
|
opacity: 0 |
|
|
|
}) |
|
|
|
|
|
|
|
let typewriterElements = document.querySelectorAll('.typewriter-text') |
|
|
|
|