css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
<header>
    <aside>
        <ul>
            <li><button type="button" id="btn-envol">envoler</button></li>
            <li><button type="button" id="btn-deposer">déposer</button></li>
        </ul>
    </aside>
</header>


<article class="main">
    <!-- Add your site or application content here -->
    <h1>Les paroles s'envolent et les écrits restent ?</h1>


  <p class="to-wrap anim-envol">
    Sur la pente du talus les anges tournent leurs robes de laine dans les herbages d’acier et d’émeraude.</p>
  <p>
    Des prés de flammes bondissent jusqu’au sommet du mamelon. À gauche le terreau de l’arête est piétiné par tous les homicides et toutes les batailles, et tous les bruits désastreux filent leur courbe. Derrière l’arête de droite la ligne des orients, des progrès.
  </p>
Et tandis que la bande en haut du tableau est formée de la rumeur tournante et bondissante des conques des mers et des nuits humaines,

La douceur fleurie des étoiles et du ciel et du reste descend en face du talus, comme un panier, — contre notre face, et fait l’abîme fleurant et bleu là-dessous.
            </span>
    <h3>gros span</h3>

        <span class="to-wrap anim-deposer">
            Sur la pente du talus les anges tournent leurs robes de laine dans les herbages d’acier et d’émeraude.

Des prés de flammes bondissent jusqu’au sommet du mamelon. À gauche le terreau de l’arête est piétiné par tous les homicides et toutes les batailles, et tous les bruits désastreux filent leur courbe. Derrière l’arête de droite la ligne des orients, des progrès.

Et tandis que la bande en haut du tableau est formée de la rumeur tournante et bondissante des conques des mers et des nuits humaines,

La douceur fleurie des étoiles et du ciel et du reste descend en face du talus, comme un panier, — contre notre face, et fait l’abîme fleurant et bleu là-dessous.
        </span>
    <a href="https://fr.wikisource.org/wiki/Mystique">Arthur Rimbaud -- Mystique</a>
    <h2>Paragraph (with childs)</h2>

    <p class='poesie to-wrap anim-envol'>
        Dans le chant de ma colère il y a un œuf,
        Et dans cet œuf il y a ma mère, mon père et mes enfants,
        Et dans ce tout il y a joie et tristesse mêlées, et vie.
        Grosses tempêtes qui m'avez secouru,
        Beau soleil qui m'as contrecarré,
        Il y a haine en moi, forte et de date ancienne,
        Et pour la beauté on verra plus tard.
        Je ne suis, en effet, devenu dur que par lamelles;
        Si l'on savait comme je suis resté moelleux au fond.
        Je suis gong et ouate et chant neigeux,
        Je le dis et j'en suis sûr.

        HENRI MICHAUX

        <a href="https://fr.wikipedia.org/wiki/Henri_Michaux">Henri Michaux</a>
        <cite><a href="https://fr.wikipedia.org/wiki/Henri_Michaux">Henri Michaux</a></cite>
    </p>

    <h2>several kinds of blockquotes</h2>

    <blockquote class='poesie to-wrap anim-deposer'>
        ◇♼☤☢☠⚧⚣⚢⚤⚦⚥⚨⚭❤Je rêve aux images élémentaires, aux rêves que d'autres en d'autres situations, d'autres temps et lieux, en des corps différents surtout... ont pu avoir.

        <footer>
            — <cite><a href="https://fr.wikipedia.org/wiki/Henri_Michaux">Henri Michaux</a></cite>
        </footer>
    </blockquote>

    <blockquote class="poesie to-wrap anim-deposer">« Un jour de l’an passé, sur le pont des Arts, quelqu’un de mes confrères de l’Institut se plaignit devant moi de l’ennui de vieillir. “C’est encore, lui répondit Sainte-Beuve, le seul moyen qu’on ait trouvé de vivre longtemps.” J’ai usé de ce moyen, et je sais ce qu’il vaut. »<footer class="toto">Anatole FRANCE, <cite>le Crime de Sylvestre Bonnard</cite>.</footer></blockquote>

</article>

<script>
    

</script>


            
          
!
            
              header{
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size:1.2em;
    position: fixed;
    left:0;
    width: 15%;
    background-color: #f4f4f4;
    opacity: 0.1;
    -webkit-transition:all 0.15s ease-in;
    transition:all 0.15s ease-in;
}

header:hover{opacity: 1;background-color: #BADA55;}

header ul {list-style-type: none; margin:0;padding: 1em;}
header ul li{line-height: 1.3em; margin:0.75em 0;}
header li a{color:#333; text-decoration:none;}
header button {padding: 0.5em 1em;}

.main{
    position: relative;
    width: 60%;
    padding-left:10%;
    max-width: 50em;
    margin:10em auto 10em auto;
    font-family: 'calendas_plusregular', serif; font-size:1.2em;
    -webkit-font-variant-ligatures:common-ligatures;
    -moz-font-variant-ligatures:common-ligatures;
    font-variant-ligatures:common-ligatures;
    text-rendering:optimizeLegibility;
}

h1{color: #e51a14; -webkit-font-feature-settings:"frac" 1, "liga" 1, "dlig" 1, "hlig" 1, "clig" 1, "swsh" 1, "calt" 1, "hist" 1, "salt" 1, "ss01" 1, "ss02" 1, "ss03" 1, "ss04" 1, "ss05" 1; -moz-font-feature-settings:"frac" 1, "liga" 1, "dlig" 1, "hlig" 1, "clig" 1, "swsh" 1, "calt" 1, "hist" 1, "salt" 1, "ss01" 1, "ss02" 1, "ss03" 1, "ss04" 1, "ss05" 1; font-feature-settings:"frac" 1, "liga" 1, "dlig" 1, "hlig" 1, "clig" 1, "swsh" 1, "calt" 1, "hist" 1, "salt" 1, "ss01" 1, "ss02" 1, "ss03" 1, "ss04" 1, "ss05" 1;}

.poesie{}
.poesie footer{font-family: sans-serif; font-size: 1rem;}



/* base for wrappers */
.wrapper{
    /*display: inline-block;position: fixed;*/
    line-height: 1em;
	background-color: transparent;
    -webkit-transform: rotateZ(0);
    -ms-transform: rotateZ(0);
    transform: rotateZ(0);
}



/* "envol" animation */
/* debug
.anim-envol .wrapper:nth-of-type(2n+1){background-color: yellowgreen;}
.anim-envol .wrapper:nth-of-type(3n){background-color: orange;}
.anim-envol .wrapper:nth-of-type(5n){background-color: lightskyblue;}
 */
.anim-envol{
    /*transform-style: preserve-3d;
    perspective:700px;*/
}
.anim-envol .wrapper{
    -webkit-transition:all 2.5s ease-in;
    transition:all 2.5s ease-in;
}

.anim-envol .wrapper.envol{
    position:relative;
    line-height: 1em;
    display:inline-block;
    -webkit-transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
    -ms-transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
    transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
    /*animation : envol1 2.5s ease-in 1; animation-fill-mode: both;*/
}

.anim-envol .wrapper.envol:nth-of-type(3n){
    /*animation : envol2 2.5s ease-in 1; animation-fill-mode: both;*/
    -webkit-transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
    -ms-transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
    transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
}

.anim-envol .wrapper.envol:nth-of-type(5n){
    /*animation : envol3 2.5s ease-in 1; animation-fill-mode: both;*/
    -webkit-transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
    -ms-transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
    transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
}


/* Animations */


/* "envole" effect */

@-webkit-keyframes envol1 {
    0% {}
    50% {}
    100% {
        -webkit-transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
        transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
        opacity: 0;
    }
}

@keyframes envol1 {
    0% {}
    50% {}
    100% {
        -webkit-transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
        -ms-transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
        transform: translateY(-100em) rotateY(-200deg) rotateZ(360deg) scale3D(2,2,2);
        opacity: 0;
    }
}
@-webkit-keyframes envol2 {
    0% {}
    50% {}
    100% {
        -webkit-transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
        transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
        opacity: 0;
    }
}
@keyframes envol2 {
    0% {}
    50% {}
    100% {
        -webkit-transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
        -ms-transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
        transform: translateY(-100em) translateX(5em) rotateY(360deg) rotateZ(-470deg) scale3D(3,3,3);
        opacity: 0;
    }
}
@-webkit-keyframes envol3 {
    0% {}
    50% {}
    100% {
        -webkit-transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
        transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
        opacity: 0;
    }
}
@keyframes envol3 {
    0% {}
    50% {}
    100% {
        -webkit-transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
        -ms-transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
        transform: translateY(-100em) translateX(-5em) rotateY(100deg) rotateZ(-256deg) scale3D(3,3,3);
        opacity: 0;
    }
}

/* "depose" effect */
/* debug */
/*
.anim-deposer .wrapper{background-color: red;}
.anim-deposer .wrapper:nth-of-type(3n){background-color: pink;}
.anim-deposer .wrapper:nth-of-type(5n){background-color: #ffff00;}*/


.anim-deposer{font-size: 1em;}
.anim-deposer .wrapper{  position:relative;
    display:inline-block; opacity: 0;}

.anim-deposer .wrapper.deposer{
    -webkit-animation: deposer1 3s ease-in-out 1;
    animation: deposer1 3s ease-in-out 1; -webkit-animation-fill-mode:both; animation-fill-mode:both;
}

.anim-deposer .wrapper.deposer:nth-of-type(3n){
    -webkit-animation: deposer2 3s ease-in-out 1;
    animation: deposer2 3s ease-in-out 1; -webkit-animation-fill-mode:both; animation-fill-mode:both;
}

.anim-deposer .wrapper.deposer:nth-of-type(5n){
    -webkit-animation: deposer3 3s ease-in-out 1;
    animation: deposer3 3s ease-in-out 1; -webkit-animation-fill-mode:both; animation-fill-mode:both;
}

@-webkit-keyframes deposer1 {
    0% {opacity:0; -webkit-transform: translateY(-100em) rotateX(150deg) rotateZ(600deg)  rotateY(-800deg) scale3D(2,2,2); transform: translateY(-100em) rotateX(150deg) rotateZ(600deg)  rotateY(-800deg) scale3D(2,2,2);}
    50% {}
    99% {

    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0em) scale3D(1,1,1);
        transform: translateY(0em) scale3D(1,1,1);;
    }
}

@keyframes deposer1 {
    0% {opacity:0; -webkit-transform: translateY(-100em) rotateX(150deg) rotateZ(600deg)  rotateY(-800deg) scale3D(2,2,2); -ms-transform: translateY(-100em) rotateX(150deg) rotateZ(600deg)  rotateY(-800deg) scale3D(2,2,2); transform: translateY(-100em) rotateX(150deg) rotateZ(600deg)  rotateY(-800deg) scale3D(2,2,2);}
    50% {}
    99% {

    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0em) scale3D(1,1,1);
        -ms-transform: translateY(0em) scale3D(1,1,1);
        transform: translateY(0em) scale3D(1,1,1);;
    }
}
@-webkit-keyframes deposer2 {
    0% {opacity: 0; -webkit-transform: translateY(-100em) rotateY(-300deg) rotateZ(-900deg)  rotateY(-800deg) scale3D(3,3,3); transform: translateY(-100em) rotateY(-300deg) rotateZ(-900deg)  rotateY(-800deg) scale3D(3,3,3);}
    100% {
        opacity: 1;
        -webkit-transform: translateY(0em) scale3D(1,1,1);
        transform: translateY(0em) scale3D(1,1,1);;
    }
}
@keyframes deposer2 {
    0% {opacity: 0; -webkit-transform: translateY(-100em) rotateY(-300deg) rotateZ(-900deg)  rotateY(-800deg) scale3D(3,3,3); -ms-transform: translateY(-100em) rotateY(-300deg) rotateZ(-900deg)  rotateY(-800deg) scale3D(3,3,3); transform: translateY(-100em) rotateY(-300deg) rotateZ(-900deg)  rotateY(-800deg) scale3D(3,3,3);}
    100% {
        opacity: 1;
        -webkit-transform: translateY(0em) scale3D(1,1,1);
        -ms-transform: translateY(0em) scale3D(1,1,1);
        transform: translateY(0em) scale3D(1,1,1);;
    }
}
@-webkit-keyframes deposer3 {
    0% {opacity:0; -webkit-transform: translateY(-100em) rotateZ(-1300deg) rotateY(-1000deg)  scale3D(3,3,3); transform: translateY(-100em) rotateZ(-1300deg) rotateY(-1000deg)  scale3D(3,3,3);
       }
    99% {

    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0em) scale3D(1,1,1);
        transform: translateY(0em) scale3D(1,1,1);;
    }
}
@keyframes deposer3 {
    0% {opacity:0; -webkit-transform: translateY(-100em) rotateZ(-1300deg) rotateY(-1000deg)  scale3D(3,3,3); -ms-transform: translateY(-100em) rotateZ(-1300deg) rotateY(-1000deg)  scale3D(3,3,3); transform: translateY(-100em) rotateZ(-1300deg) rotateY(-1000deg)  scale3D(3,3,3);
       }
    99% {

    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0em) scale3D(1,1,1);
        -ms-transform: translateY(0em) scale3D(1,1,1);
        transform: translateY(0em) scale3D(1,1,1);;
    }
}


/* Junk - not used */

@-webkit-keyframes test{
    0%{
        -webkit-transform:rotateX(0deg) rotateY(0deg);
        transform:rotateX(0deg) rotateY(0deg);
    }
    50%{
        -webkit-transform:rotateX(-20deg) rotateY(-30deg);
        transform:rotateX(-20deg) rotateY(-30deg);
    }
    100%{
        -webkit-transform: rotateX(-20deg) rotateY(-30deg) translateX(-200%);
        transform: rotateX(-20deg) rotateY(-30deg) translateX(-200%);
    }
}

@keyframes test{
    0%{
        -webkit-transform:rotateX(0deg) rotateY(0deg);
        -ms-transform:rotateX(0deg) rotateY(0deg);
        transform:rotateX(0deg) rotateY(0deg);
    }
    50%{
        -webkit-transform:rotateX(-20deg) rotateY(-30deg);
        -ms-transform:rotateX(-20deg) rotateY(-30deg);
        transform:rotateX(-20deg) rotateY(-30deg);
    }
    100%{
        -webkit-transform: rotateX(-20deg) rotateY(-30deg) translateX(-200%);
        -ms-transform: rotateX(-20deg) rotateY(-30deg) translateX(-200%);
        transform: rotateX(-20deg) rotateY(-30deg) translateX(-200%);
    }
}



            
          
!
            
              var textSlicer = (function() {

    var textSlicer = {};

    textSlicer.test = function() {
        //console.log("test OK");
    };

    //une fonction qui wrappe les caractères d'une balise par une balise spécifiée

    //une fonction qui wrappe les mots d'une balise par une balise spécifiée

    //une fonction qui wrappe les mots d'une balise par une balise spécifiée et qui wrappe les caractères de ces mots par une autre balise

    /**
     *
     * @param {NodeList} elements
     * @param {String} flagClass
     * @param {String} wrapperTag
     * @param {String} wrapperClass
     */
    textSlicer.wrapCharacters = function wrapCharacters(elements, flagClass, wrapperTag, wrapperClass) {
        for (var l = 0; l < elements.length; l++) {
            var element = elements[l];
            element.classList.add(flagClass);
            var child = element.firstChild;
            //var child = element;
            //child.normalize();
            while (child) {
                // have to get a reference before we replace the child node
                var nextSibling = child.nextSibling;

                if (child.nodeType === 1) { // element node : recurse
                    textSlicer.wrapCharacters([child], flagClass, wrapperTag, wrapperClass);
                } else if (child.nodeType === 3) { // text node
                    var d_ = document.createDocumentFragment();
                    //console.log(child.textContent);

                    for (var i = 0, len = child.textContent.length; i < len; i++) {
                        var char = child.textContent.charAt(i);

                        var span = document.createElement(wrapperTag);
                        if (char !== " " && char !== "\r" && char !== "\n" && char !== '\t' && char !== '\b' && char !== '\f') { //f(char!==" "&& char!=="\r" && char!=="\n" && char !=='\t'){
                            span.classList.add(wrapperClass);
                        }
                        span.innerHTML = char;
                        d_.appendChild(span);

                    }
                    // document fragments are just awesome
                    child.parentNode.replaceChild(d_, child);
                }
                child = nextSibling;
            }
        }
    };

    // Callback version : use acustom function to generate something with letters
    textSlicer.wrapCharactersFn = function wrapCharactersFn(elements, flagClass, wrapperTag, wrapperClass, callback) {
        for (var l = 0; l < elements.length; l++) {
            var element = elements[l];
            element.classList.add(flagClass);
            var child = element.firstChild;
            //var child = element;
            //child.normalize();
            while (child) {
                // have to get a reference before we replace the child node
                var nextSibling = child.nextSibling;

                if (child.nodeType === 1) { // element node
                    textSlicer.wrapCharactersFn(child, flagClass, wrapperTag, wrapperClass, callback);
                } else if (child.nodeType === 3) { // text node
                    var __ret = this.wrapChars(child, wrapperTag, wrapperClass);
                    var d_ = __ret.d_;
                    var i = __ret.i;
                    var len = __ret.len;
                    var char = __ret.char;
                    var span = __ret.span;
                }
                child = child.nextSibling;
            }
        }
    };
    /**
     * Slice a text content to words, wrap each word with the provided wrapperTag, eventually using the provided wrapperClass
     * @return {documentFragment}
     */
    textSlicer.processor_words = function processor_words(textContent, wrapperTag, wrapperClass) {
        //TODO : extract a function returning a documentFragment
        var d_ = document.createDocumentFragment();

        //console.log(child.textContent);
        var words = textContent.trim().split(/\s+/);

        for (var i = 0, len = words.length; i < len; i++) {
            var word = words[i];

            var span = document.createElement(wrapperTag);
            var space = document.createElement(wrapperTag); // put a space afterwards

            span.innerHTML = word; // put the word
            span.classList.add(wrapperClass);
            space.innerHTML = " ";
            d_.appendChild(span);
            d_.appendChild(space);
        }

        return d_;
    };
    /**
     * Slice a text content to chars. Wrap each char with the provided wrapperTag, enventually using the provided wrapperClass
     * @param  {[type]} textContent
     * @param  {[type]} wrapperTag
     * @param  {[type]} wrapperClass
     * @return {documentFragment}
     */
    textSlicer.processor_chars = function processor_chars(textContent, wrapperTag, wrapperClass) {
        var d_ = document.createDocumentFragment();

        for (var i = 0, len = textContent.length; i < len; i++) {
            var char = textContent.charAt(i);

            var span = document.createElement(wrapperTag);
            if (char !== " " && char !== "\r" && char !== "\n" && char !== '\t' && char !== '\b' && char !== '\f') { //f(char!==" "&& char!=="\r" && char!=="\n" && char !=='\t'){
                span.classList.add(wrapperClass);
            }
            span.innerHTML = char;
            d_.appendChild(span);
        }

        return d_;
    };

    /**
     * Process and wrap recursively an array of DOM nodes
     *
     * @param  {Array} elements : Array of DOM node to process
     * @param  {String} flagClass : class added to the DOM element to be recursed and processed
     * @param  {String} wrapperTag : HTML tag to wrap things with
     * @param  {String} wrapperClass : this class is set to wrapped elements ()
     * @param  {Function} processTextNode : function processing the text content of the node and returning a document fragment to replace the given node
     * @return {[type]}
     */
    textSlicer.wrap = function wrap(elements, flagClass, wrapperTag, wrapperClass, processTextNode) {
        //element.classList.add('word-wrapped');
        //element.normalize();
        //var text = element.textContent;
        //var words = //.exec(text);
        for (var l = 0; l < elements.length; l++) {
            var element = elements[l];
            element.classList.add(flagClass);
            var child = element.firstChild;
            //var child = element;
            //child.normalize();
            while (child) {
                // have to get a reference before we replace the child node
                var nextSibling = child.nextSibling;

                if (child.nodeType === 1) { // element node
                    textSlicer.wrap([child], flagClass, wrapperTag, wrapperClass, processTextNode);
                } else if (child.nodeType === 3) { // text node
                    child.parentNode.replaceChild(processTextNode(child.textContent, wrapperTag, wrapperClass), child);
                }
                child = nextSibling;
            }
        }
    };


    textSlicer.wrapWords = function(elements, flagClass, wrapperTag, wrapperClass) {
        //element.classList.add('word-wrapped');
        //element.normalize();
        //var text = element.textContent;
        //var words = //.exec(text);
        for (var l = 0; l < elements.length; l++) {
            var element = elements[l];
            element.classList.add(flagClass);
            var child = element.firstChild;
            //var child = element;
            //child.normalize();
            while (child) {
                // have to get a reference before we replace the child node
                var nextSibling = child.nextSibling;

                if (child.nodeType === 1) { // element node
                    textSlicer.wrapWords([child], flagClass, wrapperTag, wrapperClass);
                } else if (child.nodeType === 3) { // text node

                    //TODO : extract a function returning a documentFragment
                    var d_ = document.createDocumentFragment();

                    //console.log(child.textContent);
                    var words = child.textContent.trim().split(/\s+/);

                    for (var i = 0, len = words.length; i < len; i++) {
                        var word = words[i];

                        var span = document.createElement(wrapperTag);
                        var space = document.createElement(wrapperTag); // put a space afterwards

                        span.innerHTML = word; // put the word
                        span.classList.add(wrapperClass);
                        space.innerHTML = " ";
                        d_.appendChild(span);
                        d_.appendChild(space);

                    }
                    // document fragments are just awesome
                    child.parentNode.replaceChild(d_, child);
                }
                child = nextSibling;
            }
        }


    };
    return textSlicer;
}());


//textSlicer.wrapCharacters(document.querySelectorAll('.to-wrap, .anim-deposer'),'wrapped','span','wrapper');


// querySelector, jQuery style
var $ = function(selector) {
    return document.querySelectorAll(selector);
};

var matches;

(function(doc) {
    matches =
        doc.matchesSelector ||
        doc.webkitMatchesSelector ||
        doc.mozMatchesSelector ||
        doc.oMatchesSelector ||
        doc.msMatchesSelector;
})(document.documentElement);

// *****

var elements = $('.anim-envol');

for (var i = elements.length - 1; i >= 0; i--) {
    elements[i].addEventListener("mouseover", function(e) {
        if (matches.call(e.target, '.anim-envol .wrapper')) {
            e.target.classList.add("envol");
        }

    }, false);
}

elements = $(".anim-deposer");

for (i = elements.length - 1; i >= 0; i--) {
    elements[i].addEventListener("mouseover", function(e) {
        if (matches.call(e.target, '.anim-deposer .wrapper')) {
            e.target.classList.add("deposer");
        }

    }, false);
}

/**
 *
 * @param containerClass
 * @param wrapperClass
 * @param animClass
 * @param durationMax
 */

function triggerDelayedAnim(containerClass, wrapperClass, animClass, durationMax) {
    var elements = document.querySelectorAll('.' + containerClass + ' .' + wrapperClass);
    //console.dir(elements);
    for (i = elements.length - 1; i >= 0; i--) {
        (function triggerAnim(el) {
            setTimeout(function() {
                el.classList.add(animClass);
            }, Math.random() * durationMax);
        })(elements[i]);
    }
}

var btnEnvol = document.getElementById("btn-envol").addEventListener("click", function() {
    triggerDelayedAnim("anim-envol", "wrapper", "envol", 10000);
});


var btnDeposer = document.getElementById("btn-deposer").addEventListener("click", function() {
    triggerDelayedAnim("anim-deposer", "wrapper", "deposer", 10000);
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console