JSFiddle - React, Tailwind, and code Playground

HTML

<div id="animate">Some stuff</div>

JavaScript

(function($){

    $(function(){  //document.ready

    });

    (function customSwipe(element) {
        element
            .animate({"margin-left" : "150px"}, 1000)
            .animate({"margin-left" : "50px"}, 1000, function(){
                setTimeout(function(){
                    customSwipe(element);
                }, 0);
            });
    })($('#animate'));

})(jQuery);