css - 如何使弯曲的、扩大的圆圈、滚动过渡更加戏剧化以匹配此站点示例
问题描述
我正在尝试复制这种过渡(绿色,弯曲,全屏滚动)https://www.lower.com/save 我在这个小提琴中得到了它:https ://jsfiddle.net/egLhuvjt/ 但我有一个很难让圆圈从中心扩展而不必在左侧定义起始位置 - 一旦扩展,我也无法让溢出 x 隐藏圆圈。
$(window).scroll(function () {
const scrollTop = $(window).scrollTop();
const documentHeight = $(document).height();
const windowHeight = $(window).height();
const scrollPercent = (scrollTop / (documentHeight - windowHeight)) * 60;
const $circle = $('.blue');
growAnimation($circle, scrollPercent);
});
function growAnimation($element, animationPercentage) {
const animationDecimal = easeInOutQuad(animationPercentage / 100);
const finishSizePercent = 400;
const finishPositionPercent = -145;
const startPositionPercent = 50;
const currentSizePercent = getProgressFromTo(0, finishSizePercent, animationDecimal);
const currentPositionPercent = getProgressFromTo(startPositionPercent, finishPositionPercent, animationDecimal);
$element.css({
width: `${currentSizePercent}%`,
height: `${currentSizePercent}%`,
top: `${currentPositionPercent}%`,
left: `${currentPositionPercent}%`
});
}
function getProgressFromTo(from, to, animationDecimal) {
return from + (to - from) * animationDecimal;
}
// Taken from https://gist.github.com/gre/1650294
function easeInOutQuad(t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t }
解决方案
推荐阅读
- docusignapi - 更改发件人在 Docusign 中看到的措辞
- java - 为什么java线程在处理后没有被杀死
- java - linux上的java和pcap4j加载类的问题
- python - 使用外部参数实现自定义 keras 指标
- ravendb - 从 RavenDB Studio 的集合中删除字段
- python - 提取置换(spacy)输出依赖连接
- java - 无法访问 Android 更改系统设置权限
- multidimensional-array - 如何读取一个目录中的所有 NetCDF 文件并创建一个具有相同变量属性的单个 NetCDF 文件?
- python - 如何获取交易从未超过每月限额的行?
- c# - 您可以在 Dictionary 中的 ValueTuple 值中声明项目名称吗?