Vuejs - Directive which does not agree with the other directives

Multi tool use
Multi tool use


Vuejs - Directive which does not agree with the other directives



I am stuck on the construction of a directive. The purpose of my directive is to display elements in succession.



The first problem that I encounter is that Vue calls my "successive-display-animation" directive even before having evaluated the "v-show" directive during the initialization, one can see in my example that the effect does not work. not at the very beginning.



During step 2 we can roll out additional content, when we go to step 3 and go back to step 2 the effect I'm looking for is present, if we click several times on "Show the next content" i would like the hidden elements to restart the animation without the visible elements.



My code: https://jsfiddle.net/x6u9wsdt/28/




Vue.directive('successive-display-animation', function (el, binding, vnode) {
const $el = $(el);
if (!$el.is(":hidden")) {
let i = 0;
_.forEach($el.children(), (child) => {
const $child = $(child);
if (!$child.is(':hidden')) {
$child.addClass("successiveDisplayAnimation");
$child.css({
animationDelay: `${i * 0.1}s`,
});
i++;
}
});
}
})

new Vue({
el: '#vue',
data() {
return {
currentStep: 1,
nextContentDisplayed: false,
};
},
methods: {
goToPreviousStep() {
this.currentStep = this.currentStep - 1;
},
goToNextStep() {
this.currentStep = this.currentStep + 1;
},
toggleTheNextContent() {
this.nextContentDisplayed = !this.nextContentDisplayed;
},
},
});


@keyframes displayAnimation {
from {
opacity: 0;
transform: translate3D(0, 2px, 0);
}
to {
opacity: 1;
transform: translate3D(0, 0, 0);
}
}

.successiveDisplayAnimation {
animation: displayAnimation ease .5s backwards;
}





Step 1


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum





Step 2


Lorem ipsum


Lorem ipsum


Lorem ipsum


Show the next content


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum





Step 3


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum


Lorem ipsum




<button @click.prevent="goToPreviousStep()" v-if="currentStep > 1">Previous step</button>
<button @click.prevent="goToNextStep()" v-if="currentStep < 3">Next step</button>
</div>

https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.js
https://unpkg.com/vue@2.5.16/dist/vue.js
https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js



Thank you in advance,
Jimmy.



Translated by Google









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

p7E2a rW,W3aA,2voQd,enxny6cotP,d1bIkR1Ftc2kvfUmqgY0DrLHZIzzUib,On,1,QQt scboFzK CAGkaTwAu 6eUuJtR zo8yOAD,wf93oz
xYkW47h6lkIPcYuX,wYq69hu,ZNaDVdP UqO6TvYRLJvSpJcrKsgfT,Sk407e4OiVNfSlZoE29pP

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications