javascript - javascript/jquery .animate() 色相旋转
问题描述
你可以使用 .animate() 来动画色相旋转吗?如果没有,是否有可以在此函数中设置动画的属性列表。此链接:https ://api.jquery.com/animate 暗示 .animate() 只是一个 jQuery 函数,但它在我的项目上工作而不使用 jQuery。这是否已被 javascript 所吸收,以及如何通过 javascript 操作 css hue-rotate。我在谷歌或堆栈交换上找不到很多对此的引用。
我尝试了许多 hueRotate 的组合,使其成为对象、json 并通过 `` 创建字符串文字,但它们似乎都不起作用。
Info.style.filter = ('hueRotate:240deg;');
Info.style.filter = `hue-rotate(240deg);`
Info.style.filter = {(hue-rotate(240deg)};
Info.style.filter.hueRotate = "240deg";
我已经在 .animate 和 requestAnimationFrame 内外尝试了几十种组合,但没有一个有效。它可能真的很简单。
解决方案
是的,网络动画也可以为过滤器设置动画,就像任何可动画的 CSS 属性一样。您只需指定初始值和最终值。
document.getElementById("box").animate(
{
filter: ['hue-rotate(0deg)', 'hue-rotate(360deg)']
},
{
duration: 2500,
iterations: Infinity
}
);
#box {
background: linear-gradient( to right, purple, orange);
width: 200px;
height: 200px;
}
<div id="box"></div>
那么它实际上可以用许多不同的语法编写......
推荐阅读
- javascript - 错误:无法创建图表:无法从给定项目获取上下文
- mysql - Mysql MATCH AGAINST IN BOOLEAN MODE 无法正常工作
- hadoop - HiveServer2 尝试在不同节点的 /var/log/hive/operation_logs/ 下写入日志文件
- java - 如何找到匿名jtextfield的文本
- excel - 如何像 Power Query 一样使用 VBA 取消固定数量的列
- kubernetes - 有没有办法在一个 kubectl 命令中检查多个 pod
- powershell - 根据属性值将 .PST 导出到两个位置的命名文件夹
- c# - 在 Win32_NetworkAdapterConfiguration 类中使用 ManagementObjectSearcher 进行 LINQ 查询
- java - 通用函数不接受自定义 RowMapper 作为参数
- node.js - npm install 并在 node-gyp 重建时失败,使用 ```gyp: No Xcode or CLT version detected!``` 由新的 macos catalina 更新引起