desandro / 3dtransforms

:package: Introduction to CSS 3D transforms
https://3dtransforms.desandro.com/
1.01k stars 163 forks source link

A quick sidenote #23

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi, I didnt looked over all the project, only how to flip the card.

and i noticed that https://desandro.github.io/3dtransforms/examples/card-01.html used a js library. after a quick search i found this: https://stackoverflow.com/questions/14615712/toggle-classname-onclick-javascript

dunno if is interesting to have it without dependencies, but sharing:

<script>
document.getElementById('flip').onclick = function() {
  var card = document.getElementById('card');
    var className = ' ' + card.className + ' ';

    card.className = ~className.indexOf(' flipped ') ?
                         className.replace(' flipped ', ' ') :
                         this.className + ' flipped';
}
</script>

Best regards,

desandro commented 7 years ago

This article was written in 2010. Now in 2017, you should use classList