Javascript 自定义光标移动缓慢
我已经编写了下面的代码来在我的网页上创建自定义光标样式,但是光标在网页上移动非常缓慢。是什么导致了这种缓慢Javascript 自定义光标移动缓慢,javascript,html,css,Javascript,Html,Css,我已经编写了下面的代码来在我的网页上创建自定义光标样式,但是光标在网页上移动非常缓慢。是什么导致了这种缓慢 var cursor=document.getElementById(“cursor”); cursor.style.transition=“ease-in-out.2s”; document.onmousedown=()=>{ cursor.style.transform=“比例(0.4)”; }; document.onmouseup=()=>{ cursor.style.trans
var cursor=document.getElementById(“cursor”);
cursor.style.transition=“ease-in-out.2s”;
document.onmousedown=()=>{
cursor.style.transform=“比例(0.4)”;
};
document.onmouseup=()=>{
cursor.style.transform=“缩放(1)”;
};
document.onmousemove=(e)=>{
cursor.style.top=((e.clientY-15)+“px”);
cursor.style.left=((e.clientX)+“px”);
};代码>
正文{
光标:无;
}
#光标{
位置:绝对位置;
z指数:9;
背景色:透明;
文本对齐:居中;
边界半径:70%;
边框:1px实心#D3;
位置:固定;
光标:无;
}
o
这是由于应用于光标的过渡动画造成的。参见<代码>第2行< /代码>,并考虑:
0.1s
表示转换持续时间
ease-in-out
或linear
表示过渡easing
(例如,是什么导致了这种恼人和跳跃式的延迟)
如果你想更多地了解不同的过渡期评估,我建议你看一看,然后
var cursor=document.getElementById(“cursor”);
cursor.style.transition=“线性0.1s”;
document.onmousedown=()=>{
cursor.style.transform=“比例(0.4)”;
};
document.onmouseup=()=>{
cursor.style.transform=“缩放(1)”;
};
document.onmousemove=(e)=>{
cursor.style.top=((e.clientY-15)+“px”);
cursor.style.left=((e.clientX)+“px”);
};代码>
正文{
光标:无;
}
#光标{
位置:绝对位置;
z指数:9;
背景色:透明;
文本对齐:居中;
边界半径:70%;
边框:1px实心#D3;
位置:固定;
光标:无;
/*为什么光标离开此位置时会触发*/
}
o
这是由于应用于光标的过渡动画造成的。参见<代码>第2行< /代码>,并考虑:
0.1s
表示转换持续时间
ease-in-out
或linear
表示过渡easing
(例如,是什么导致了这种恼人和跳跃式的延迟)
如果你想更多地了解不同的过渡期评估,我建议你看一看,然后
var cursor=document.getElementById(“cursor”);
cursor.style.transition=“线性0.1s”;
document.onmousedown=()=>{
cursor.style.transform=“比例(0.4)”;
};
document.onmouseup=()=>{
cursor.style.transform=“缩放(1)”;
};
document.onmousemove=(e)=>{
cursor.style.top=((e.clientY-15)+“px”);
cursor.style.left=((e.clientX)+“px”);
};代码>
正文{
光标:无;
}
#光标{
位置:绝对位置;
z指数:9;
背景色:透明;
文本对齐:居中;
边界半径:70%;
边框:1px实心#D3;
位置:固定;
光标:无;
/*为什么光标离开此位置时会触发*/
}
o
你所说的“光标离开此位置时为什么会触发”是什么意思?你有一个片段要显示吗?我不小心从另一个地方粘贴了css注释,这里有一个片段@ale917k你说的“光标离开这个位置时为什么会触发”是什么意思?你有一个片段要显示吗?我不小心从另一个地方粘贴了css注释,这里有一个片段@ale917k