javascript - 缓入出在第一次运行时变得即时?
问题描述
我有这段代码,它不会缓和或缓和图像,而是立即显示它们?
但它似乎没有这样做?- 它立即出现?
为什么?
<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<style>
.features-read-mode {
position: relative;
overflow: hidden;
transition: max-height 21s ease-in-out;
}
</style>
<script>
$('.js-feature').each(function()) {
var self = $(this);
var startPosition;
var totalFeatures = self.children().length;
var maxHeightBuffer = 500;
function getMaxHeight() {
var maxHeight = 0;
for (var i = 0; i < totalFeatures; i++)
{
maxHeight += self.children().eq(i),height();
}
maxHeight += maxHeightBuffer;
return maxHeight;
}
function expand() {
setTimeOut(function() {
self.css('max-height', getMaxHeight() + 'px');
}, 1);
}
function collapse(startPos) {
self.css('max-height', startPos + 'px');
}
self.find('.js-button-expand-collapse').on('click', function() {
collapse(startPosition);
} else {
startPosition = self.height();
self.addClass('features-read-more--expanded');
expand();
}
});
}
</script>
</html>
该函数调用 expand ,然后更新转换应该缓入出的 maxHeight 值。这仅在执行一次后才有效。第一次执行不会缓入,而是立即进入最大高度?怎么来的?
解决方案
推荐阅读
- vb.net - 任务基础:任务与应用程序的多个实例
- pipeline - 使用 cli 或 API 部署 Kubeflow 管道,而不是在 UI 上
- android - 将机器学习套件与 NNAPI 结合使用
- android - 从第一个活动到第二个活动时出错
- spring - 带有本地存储库的 Spring Cloud Config Server 配置
- c# - 导航菜单为空
- javascript - 是否有一种简单的方法(希望使用 ES6+)基于配置对象对数组值应用突变?
- sql - Oracle Reports Builder - 检查查询是否为空
- c - C 字符串的行为很奇怪
- c# - XAML 如何创建响应式 TextBlock?