JSFiddle - React, Tailwind, and code Playground

HTML

<div class="output"></div>

JavaScript

var obj = {
    left: 0
};

function autoScroll() {
    console.log("starting", obj.left);
    $(obj).animate({
        left: '-=100'
    }, {
        duration: 1000,
        easing: 'linear',
        complete: autoScroll,
        step: function(val) {
            $('.output').append("step value: " + val + "<br/>actual value: " + this.left, "<br/>");   
            if (this.left < -80) {
                $(this).stop(true);
                
                this.left += 80;
                $('.output').append("stopped += 80 ", this.left, "<br/>");
                autoScroll();
            }
        }
    });
}

autoScroll();