
Function to Add Scaling&Color Effect // Function to scale cursorĬ = " all 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19)" Ĭ = "background,transform" And t hen we call this function on mousemove.
BEST CUSTOM CURSORS CODE
PageX does the same thing as pageY but returns the X(horizontal) coordinates.Īnd the above code takes up the coordinates from pageX and pageY and s ets the top and left position for the cursor. PageY is a mouse event property that returns the Y (vertical) coordinate in pixels of the event relative to the whole document (in this case whole page). Red Cursor Movement // Function that make's red cursor move along This block of code just grabs ".cursor" and ".image-holder" and stores in a variable for later use.Īnd window.addEventListener("mousemove", animation) adds event listener on mousemove and calls function named animation which we will create in the latter part of the post. Window.addEventListener("mousemove", animation) Adding Event listner to entire screen(window) so that Let image_holder = document.querySelector(".image-holder") Let cursor = document.querySelector(".cursor") Javascript Code Explanation Grabing classes // Grabing classes So backdrop-filter: grayscale() makes image grey if that particular element with this property comes above it (in this case it is. The backdrop-filter CSS property lets you apply certain effects such as blurring or color shifting to the area behind an element. You can read more about backdrop-filter at Mdn docs You can read more about pointer-events at Mdn docs The pointer-events CSS property sets under what circumstances a particular graphic element can become the target of pointer events. But there are two property which is important here- pointer-events: none and backdrop-filter: grayscale() cursor class we just added width, height, radius, and border styling. In this class, we add the actual styling of the cursor which you want to display on the screen. cursor class is very important for this entire example. When I started to research for this project, I thought creating custom cursor is not easy but after spending 1hr of digging the internet I was able to create it. Yesterday I was surfing through dribble feeds and there I saw a UI design that used custom cursor which was looking really cool. Learn to create a simple scale hover effect.Learn to create your very first custom cursor.4.Fluent hovering effects with custom pointer.Other Complex Examples of Custom Cursor.
