Search
 
SCRIPT & CODE EXAMPLE
 

CSS

mouse cursor smooth

.cursor {
            width: 50px;
            height: 50px;
            border-radius: 100%;
            border: 1px solid black;
            transition: all 200ms ease-out;
            position: fixed;
            pointer-events: none;
            left: 0;
            top: 0;
            transform: translate(calc(-50% + 15px), -50%);
        }

        .cursor2 {
            width: 20px;
            height: 20px;
            border-radius: 100%;
            background-color: black;
            opacity: .3;
            position: fixed;
            transform: translate(-50%, -50%);
            pointer-events: none;
            transition: width .3s, height .3s, opacity .3s;
        }

        .cursor.hover {
            background-color: red;
            opacity: 0.5;
        }

        .cursorinnerhover {
            width: 50px;
            height: 50px;
            opacity: .5;
        }


<script>
        var cursor = document.querySelector('.cursor');
        var cursorinner = document.querySelector('.cursor2');
        var a = document.querySelectorAll('a');

        document.addEventListener('mousemove', function(e) {
            var x = e.clientX;
            var y = e.clientY;
            cursor.style.transform = `translate3d(calc(${e.clientX}px - 50%), calc(${e.clientY}px - 50%), 0)`
        });

        document.addEventListener('mousemove', function(e) {
            var x = e.clientX;
            var y = e.clientY;
            cursorinner.style.left = x + 'px';
            cursorinner.style.top = y + 'px';
        });

        document.addEventListener('mousedown', function() {
            cursor.classList.add('click');
            cursorinner.classList.add('cursorinnerhover')
        });

        document.addEventListener('mouseup', function() {
            cursor.classList.remove('click')
            cursorinner.classList.remove('cursorinnerhover')
        });

        a.forEach(item => {
            item.addEventListener('mouseover', () => {
                cursor.classList.add('hover');
            });
            item.addEventListener('mouseleave', () => {
                cursor.classList.remove('hover');
            });
        })
    </script>
Comment

PREVIOUS NEXT
Code Example
Css :: carousel inner item populate with for loop puting active class on all carousel item 
Css :: linux remove latst 3 files 
Css :: CSS or locator 
Css :: bolock rotating the screen on your website with css 
Css :: margin collapse 
Css :: cop pics css 
Css :: CSS - The Class Selectors 
Css :: chrome extension detect copy action 
Css :: css image grow on hover without text content 
Css :: slect all li that not have ul 
Css :: alinhar componentes css 
Css :: verified icon css 
Css :: html css on class 
Css :: on active tab background color with slide animation 
Css :: how can i make a menu bar appear by clicking an icon? in css? 
Css :: groupby 
Css :: border-style 
Css :: diagonal background color css 
Css :: how to style a particular image in css 
Css :: scss font color 
Typescript :: remove dots from li 
Typescript :: how to add image from assets inside as a decoration image in container 
Typescript :: using log how can we find number of digits for a number in java 
Typescript :: react beautiful dnd disable drag 
Typescript :: deno web server 
Typescript :: replaceall typescript 
Typescript :: dataframe value counts sort 
Typescript :: only digits pattern 
Typescript :: how to add no results found message in angular search bar 
Typescript :: event typescript 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =