Edit: px_cursor4.php
<?php $divi_PX_cursor_size = et_get_option('divi_PX_cursor_size', '40'); $divi_PX_cursor_border_color = et_get_option('divi_PX_cursor_border', '#000000'); $divi_PX_cursor_background_color = et_get_option('divi_PX_cursor_bg', 'transparent'); ?> <div id="cursor" class="px_cursor_4"></div> <div id="cursor-border" class="px_cursor_4 cursor-border"></div> <style> body { cursor: none !important; } .px_cursor_4 { position: fixed; top: 0; left: 0; width: <?php echo esc_attr($divi_PX_cursor_size); ?>px; height: <?php echo esc_attr($divi_PX_cursor_size); ?>px; background: <?php echo esc_attr($divi_PX_cursor_background_color); ?>; border-radius: 50%; pointer-events: none; z-index: 9999999999; transform: translate(-50%, -50%); transition: transform 0.15s ease, width 0.2s, height 0.2s; } .px_cursor_4.cursor-border { width: 30px; height: 30px; border-radius: 50%; border: 2px solid <?php echo esc_attr($divi_PX_cursor_border_color); ?>; background-color: transparent; } </style> <script> document.addEventListener("DOMContentLoaded", () => { const cursor = document.querySelector("#cursor"); const cursorBorder = document.querySelector("#cursor-border"); if (!cursor || !cursorBorder) return; const cursorPos = { x: 0, y: 0 }; const borderPos = { x: 0, y: 0 }; document.addEventListener("mousemove", (e) => { cursorPos.x = e.clientX; cursorPos.y = e.clientY; cursor.style.transform = `translate(${cursorPos.x}px, ${cursorPos.y}px) translate(-50%, -50%)`; }); document.addEventListener("mousedown", () => { cursor.style.transform = `translate(${cursorPos.x}px, ${cursorPos.y}px) translate(-50%, -50%) scale(1.5)`; cursorBorder.style.width = "30px"; cursorBorder.style.height = "30px"; }); document.addEventListener("mouseup", () => { cursor.style.transform = `translate(${cursorPos.x}px, ${cursorPos.y}px) translate(-50%, -50%) scale(1)`; cursorBorder.style.width = "50px"; cursorBorder.style.height = "50px"; }); function loop() { const easing = 8; borderPos.x += (cursorPos.x - borderPos.x) / easing; borderPos.y += (cursorPos.y - borderPos.y) / easing; cursorBorder.style.transform = `translate(${borderPos.x}px, ${borderPos.y}px) translate(-50%, -50%)`; requestAnimationFrame(loop); } loop(); document.addEventListener("mouseover", (e) => { const target = e.target.closest("a, button, input, textarea, select, [role='button'], [data-cursor-hover]"); if (target) { cursorBorder.style.backgroundColor = "rgba(0,0,0,0.1)"; cursorBorder.style.boxShadow = "0 0 0 1px #000"; } }); document.addEventListener("mouseout", (e) => { const target = e.target.closest("a, button, input, textarea, select, [role='button'], [data-cursor-hover]"); if (target) { cursorBorder.style.backgroundColor = "transparent"; cursorBorder.style.boxShadow = "0 0 0 1px #000"; } }); }); </script>
Save
Back