JSFiddle - React, Tailwind, and code Playground

by byrichardpowell

HTML

<div class="box">
    <p>CLICK ME TO BLUR OUT. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> 
</div>

CSS

.blur-out {
    -webkit-filter: blur(8px);
    -webkit-transform: scale(1.4, 1.4);
    opacity: 0.1;
    -webkit-transition: all 0.25s ease-out;
    transition: all 0.25s ease-out;
    visibility: hidden;
}

.box {
    
    border:2px solid #000;
    background:#fff;  
    margin: 80px; 
   padding: 20px;    
    
}

JavaScript

// Animate an element by adding a class to it:
// Paramaters: 
// anim: the class name to add
// time: animation duration (optional, fallsback to the class)
// cb: an optional callback function to happen once the animation ends
$.fn.animatecss = function(anim, time, cb) {

    // If a time was specified add the transition speed to the element
    // If not the animation defaults to the speed in the class
    if (time) this.css('-webkit-transition', time / 1000 + 's');

    // The class is the animation.
    // We dont use any javascript animation
    this.addClass(anim);

    // Was a callback provided?
    if ($.isFunction(cb)) {

        // if a time was pecified wait that long then call the cb
        // if not call the callback after 250 milliseconds       
        setTimeout(function() {

            // Ensure that the element is available inside the callback.
            $(this).each(cb);

        }, (time) ? time : 250);

    }

    // Return the elements to allow chaining
    return this;

};



$(document).ready(function() {

    // When the user clicks an element with a class of box
    $('.box').click(function() {

        // Call the jQuery/zepto pluggin
        $(this).animatecss('blur-out', 250, function() {

            // The call back gets fired after the animation
            console.log('callback');

        });


    });

});