Is there a way in JavaScript to make a <div>
slide in from the right when hovered over, without relying on jQuery or other libraries? I'm looking for a modern browser-friendly solution.
const div = document.querySelector('.from_right');
div.addEventListener('mouseover', function() {
let position = 0;
function slideIn() {
if (position > -300) {
position -= 1;
div.style.right = `${position}px`;
requestAnimationFrame(slideIn);
}
}
slideIn();
});