301}302303function showCaptureForm() {304form.classList.add('js-form-proccess');305var quizDescription = rec.querySelector('.t835__quiz-description');306var currentStep = form.querySelector('.t-step-form__step_active');307308animateStepSwitch(currentStep, captureForm, {309onAnimationStart: function () {310stepChangeInProgress = true;311312if (quizDescription) quizDescription.style.display = 'none';
if (resultTitle) resultTitle.style.display = 'block'; if (resultBtn) resultBtn.style.display = 'none'; if (submitBtnWrapper) submitBtnWrapper.style.display = 'block'; disableButtons(rec); }, onNewStepAnimationStart: function () { t835_runLazyLoad(); enableButtons(rec); stepChangeInProgress = false; t835_adjustStepToHeight(rec); }, }); return; } /** * @typedef {Object} AnimationCallbacks * @property {Function=} onAnimationStart функция, выполняемая перед началом анимации. * @property {Function=} onAnimationComplete функция, выполняемая после завершения анимации. * @property {Function=} onNewStepAnimationStart функция, выполняемая после начала анимации появления нового шага. */ /** * * @param {HTMLElement} step шаг, который нужно скрыть * @param {HTMLElement} newStep шаг, который нужно показать * @param {AnimationCallbacks} callbacks */ function animateStepSwitch(step, newStep, callbacks) { function handleFadeInEnd() { newStep.classList.remove('t-step-form__step_fadeIn'); newStep.removeEventListener('animationend', handleFadeInEnd); newStep.removeEventListener('animationcancel', handleFadeInCancel); if (callbacks.onAnimationComplete) { callbacks.onAnimationComplete(); } } function handleFadeInCancel() { newStep.classList.remove('t-step-form__step_fadeIn'); newStep.removeEventListener('animationend', handleFadeInEnd); newStep.removeEventListener('animationcancel', handleFadeInCancel); } function animateStepIn() { newStep.addEventListener('animationend', handleFadeInEnd); // при быстром переключении шагов необходимо отменить анимацию newStep.addEventListener('animationcancel', handleFadeInCancel); newStep.classList.add('t-step-form__step_active'); newStep.classList.add('t-step-form__step_fadeIn'); if (callbacks.onNewStepAnimationStart) { callbacks.onNewStepAnimationStart(); } } function handleFadeOutEnd() { step.classList.remove('t-step-form__step_fadeOut'); step.classList.remove('t-step-form__step_active'); step.removeEventListener('animationend', handleFadeOutEnd); if (newStep) { animateStepIn(); } } function animateStepOut() { step.addEventListener('animationend', handleFadeOutEnd); step.classList.add('t-step-form__step_fadeOut'); } if (callbacks.onAnimationStart) { callbacks.onAnimationStart(); } if (step) { return animateStepOut(); } return animateStepIn(); } function disableButtons() { if (prevBtn) prevBtn.disabled = true; if (nextBtn) nextBtn.disabled = true; if (resultBtn) resultBtn.disabled = true; if (submitBtn) submitBtn.disabled = true; }