JSFiddle - React, Tailwind, and code Playground

by luka kupunia

HTML

<div></div>
<div></div>
<div></div>


<div id="cursor" class="MouseDiv HideMobile">
    <div class="Arrow"></div>
    <div class="More">
        <div class="Icon"></div>
        <div class="Name">გაიგე მეტი</div>
    </div>
</div>

CSS

div {
    height: 100vh;
}
#cursor {
    background: red;
    height: auto;
    width: 38px;
    height: 38px;
    position: absolute;
    top: 0;
    left: 0;
}
.HomeDiv .Content .Left .Title .MouseDiv {
    display: inline-block;
    width: 38px;
    height: 38px;
    position: absolute;
    right: -140px;
    top: 40px;
    cursor: pointer;
    transition: 0.5s;
    overflow: hidden;
}
.HomeDiv .Content .Left .Title .MouseDiv .Arrow {
    background: #00A987 url(../img/cursos_1.svg) no-repeat;
    width: 100%;
    height: 100%;
    background-position: center center;
    transition: 0.3s;
}
.HomeDiv .Content .Left .Title .MouseDiv .More {
    width: 110px;
    height: 110px;
    display: inline-block;
    position: absolute;
    left: 50%;
    margin-left: -55px;
    top: 0;
    text-align: center;
    padding-top: 20px;
    opacity: 0;
}
.HomeDiv .Content .Left .Title .MouseDiv .More .Icon {
    width: 26px;
    height: 25px;
    background: url(../img/mouse_icon.svg) no-repeat;
    background-size: 100% 100%;
    margin: 0 auto;
    margin-bottom: 20px;
}
.HomeDiv .Content .Left .Title .MouseDiv .More .Name {
    color: #FFFFFF;
    line-height: 30px;
    font-size: 14px;
}
.HomeDiv .Content .Left .Title:before {
    content: '';
    width: 100px;
    height: 120px;
    position: absolute;
    left: 90%;
    top: 0;
    background: transparent;
}

JavaScript

var elem = document.querySelector('#cursor'),

                target = {
                    x: 0,
                    y: 0
                },

                position = {
                    x: 0,
                    y: 0
                },

                ease = 0.1



            document.addEventListener('mousemove', function(e) {
                target.x = e.pageX,
                target.y = e.pageY;
            })

            function update() {
                elem.style.transform = 'translate(' + (position.x - 10.5) + 'px,' + (position.y - 10.5) + 'px)';
                position.x = position.x + (target.x - position.x) * ease;
                position.y = position.y + (target.y - position.y) * ease;

                requestAnimationFrame(update)

            }
            update();