*/ function switchSteps(oldStep, newStep, callbacks = {}) { const { onStepChange, onProgressChange } = initOptions; const { onAnimationComplete, onAnimationStart, onNewStepAnimationStart } = animation.callbacks || {}; if (!animation) { oldStep && deactivateStep(oldStep); activateStep(newStep); onStepChange && onStepChange(newStep); onProgressChange && onProgressChange(getStepsProgress()); onAnimationComplete && onAnimationComplete(oldStep, newStep); callbacks.onAnimationComplete && callbacks.onAnimationComplete(oldStep, newStep); resetAutoStepChangeProgress(); return; } t_quiz__animateSteps( oldStep, newStep, { onAnimationStart: function (oldStep, newStep) { onAnimationStart && onAnimationStart(oldStep, newStep); callbacks.onAnimationStart && callbacks.onAnimationStart(oldStep, newStep); }, onNewStepAnimationStart: function (oldStep, newStep) { onNewStepAnimationStart && onNewStepAnimationStart(oldStep, newStep); callbacks.onNewStepAnimationStart && callbacks.onNewStepAnimationStart(oldStep, newStep); onStepChange && onStepChange(newStep); onProgressChange && onProgressChange(getStepsProgress()); resetAutoStepChangeProgress(); }, onAnimationComplete: function (oldStep, newStep) { onAnimationComplete && onAnimationComplete(oldStep, newStep); callbacks.onAnimationComplete && callbacks.onAnimationComplete(oldStep, newStep); }, }, { animation: { in: getAnimationConfigForStep(newStep), out: getAnimationConfigForStep(oldStep), }, stepActiveClass: activeStepClass, stepHiddenClass: hiddenStepClass, } ); } /** * @param {Step} [step] * @returns {AnimationType} */ function getAnimationConfigForStep(step) { if (!step || typeof animation === 'string') { return animation; } return animation.type[step.type] || 'fade-with-move'; } function init() { if (isConditional) { t_onFuncLoad('t_form__conditionals_initFields', function () { var conditionalFields = t_form__conditionals_initFields(initOptions.recId); conditionalFields.addListeners(function () { initOptions.onProgressChange && initOptions.onProgressChange(getStepsProgress()); }); conditionalFields.addStateChangeListeners(function (event) { initOptions.onConditionalStateChange && initOptions.onConditionalStateChange(event); }); if (autoStepChangeEnabled) initAutoStepChange(); go('next', { onAnimationComplete: initOptions.onInit }); }); } else { if (autoStepChangeEnabled) initAutoStepChange(); go('next', { onAnimationComplete: initOptions.onInit }); } } function restart() { // Сбрасываем отображение текущего шага deactivateStep(activeStep.step); // Возвращаем состояния в первоначальный вид activeStep = INITIAL_ACTIVE_STEP; // Включаем первый шаг go('next');