JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script>
<div id="pencil">xdsdfsfsd.</div>

CSS

#pencil {
    width:100px;
    height:100px;
    background:#eee;
}

JavaScript

var rotation = function (times) {
    var el = $("#pencil");
    if(typeof times == 'number'){
        el.data('repeatRotation',times);
    } else {
        times = el.data('repeatRotation')-1;
        el.data('repeatRotation',times);
    }

    if(times > 0){
        $("#pencil").rotate({
            angle: 0,
            animateTo: 2,
            duration: 200,
            callback: rotationBack
        });
    }
}
var rotationBack = function () {


    $("#pencil").rotate({
        angle: 0,
        animateTo: -2,
        duration: 200,
        callback: rotation
    });
    
}

rotation(5);