Así que estoy tratando de crear un efecto de rastro de puntero específico. Estoy pegando el código que estoy tomando como ejemplo a continuación. El problema es que el rastro está punteado, pero estoy tratando de hacer una línea. Estoy tratando de recrear el rastro que puedes ver en este sitio: [1]: https://argor-heraeus.com/
Ejemplo del código que estoy usando:
// dots is an array of Dot objects, // mouse is an object used to track the X and Y position // of the mouse, set with a mousemove event listener below var dots = [], mouse = { x: 0, y: 0 }; // The Dot object used to scaffold the dots var Dot = function() { this.x = 0; this.y = 0; this.node = (function() { var n = document.createElement("div"); n.className = "trail"; document.body.appendChild(n); return n; }()); }; // The Dot.prototype.draw() method sets the position of // the object's <div> node Dot.prototype.draw = function() { this.node.style.left = this.x + "px"; this.node.style.top = this.y + "px"; }; // Creates the Dot objects, populates the dots array for (var i = 0; i < 12; i++) { var d = new Dot(); dots.push(d); } // This is the screen redraw function function draw() { // Make sure the mouse position is set everytime // draw() is called. var x = mouse.x, y = mouse.y; // This loop is where all the 90s magic happens dots.forEach(function(dot, index, dots) { var nextDot = dots[index + 1] || dots[0]; dot.x = x; dot.y = y; dot.draw(); x += (nextDot.x - dot.x) * .6; y += (nextDot.y - dot.y) * .6; }); } addEventListener("mousemove", function(event) { //event.preventDefault(); mouse.x = event.pageX; mouse.y = event.pageY; }); // animate() calls draw() then recursively calls itself // everytime the screen repaints via requestAnimationFrame(). function animate() { draw(); requestAnimationFrame(animate); } // And get it started by calling animate(). animate(); body { background-color: black; } .trail { /* className for the trail elements */ position: absolute; height: 6px; width: 6px; border-radius: 3px; background: gold; }Estoy jugando con los márgenes (izquierda, derecha), con el ancho, pero no puedo "pegarlos". ¿Alguien tiene una idea de cómo podría hacer una línea limpia?
Así que cambié esto en el código dado:
x += (nextDot.x - dot.x) * **0.05**; y += (nextDot.y - dot.y) * **0.05**;Y agregó más puntos, 80, para ser precisos.
También agregué una transición más fluida con estas reglas CSS
-webkit-transition:90ms; transition:90ms;