I'm playing around with https://tympanus.net/codrops/2014/03/05/simple-stack-effects/ right now but I'm struggling to use a link instead of a button as the trigger for this animation.
<button>Click me</button>
<figure class="stack stack-sidegrid">
<img src="img/1.png" alt="img01"/>
<img src="img/3.png" alt="img03"/>
<img src="img/4.png" alt="img04"/>
</figure>
change to
<a href="#">
<figure class="stack stack-sidegrid">
<img src="img/1.png" alt="img01"/>
<img src="img/3.png" alt="img03"/>
<img src="img/4.png" alt="img04"/>
</figure>
</a>
This is the js script for handling the event.
(function() {
[].slice.call( document.querySelectorAll( '.stack' ) ).forEach( function( el ) {
var togglebtt = el.previousElementSibling,
togglefn = function() {
if( classie.hasClass( el, 'active' ) ) {
classie.removeClass( el, 'active' );
}
else {
classie.addClass( el, 'active' );
}
};
togglebtt.addEventListener( 'click', togglefn );
} );
})();
Does anybody maybe have a suggestion how I get this code to work?
Reference: https://tympanus.net/codrops/2014/03/05/simple-stack-effects/