javascript - 递归动画如何在 SVG 下工作
问题描述
我指的是下面链接中给出的 svg 动画 https://codepen.io/thinkdesign/pen/JybJOq 我无法理解递归是如何工作的
var offset = 0;
var animation = function() {
offset -= 100;
pattern.animate({ x: offset }, 500, mina.ease, animation);
};
这里我们在每个函数调用上改变 x 轴,所以 x 轴应该在某个时候超出屏幕。请帮助我了解这是如何工作的
解决方案
Nothing is moving across the page here. The x
that is being moved here is the pattern's X offset. An SVG <pattern>
is a fill that consists of a "tile" that is repeated infinitely in every direction. The <pattern>
has an x
and y
attribute that tells the browser where to start the tiling from. Animating the pattern's x
offset has the effect of making it look like the tile is continuously moving across your object.
Picture a rectangular window lying on a tiled floor. If you slide that window across the floor, it looks to you like the tile pattern moves through the window.
推荐阅读
- html - 离子标签按钮在选择时不会改变颜色
- postgresql - Postgres 获取足够的视图信息来重现它
- python - 为数据点查找集群的简单方法是什么?
- codesign - 公证和签名后无法运行应用程序
- azure-application-insights - 应用程序洞察警报与可配置的电子邮件收件人和电子邮件正文的通知?
- arrays - 在 C 上处理 CSV 存档和结构数组时出现问题
- latitude-longitude - 在 OSRM 查询中查找无效坐标(纬度和经度)
- partitioning - 函数cutPoints的使用
- pandas - 标准化公司名称
- swiftui - 如何使 LazyVGrid 中的每个项目的高度相同?