- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个页面,当用户在页面上可见时,用户滚动和显示动画,当它们不可见时隐藏。每当滚动页面时都会发生这种情况,但它似乎占用了过多的处理能力,并且页面滚动相当静态。
这是我使用的代码:
$('body').scroll(function(){
$('.anim').on('inview', function (event, visible) {
if (visible == true) {
// element is now visible in the viewport
$(this).removeClass("hidden");
$(this).addClass("visible animated fadeIn");
} else {
// element has gone out of viewport
$(this).removeClass("visible animated fadeIn");
$(this).addClass("hidden");
}
});
$('.anim_bounceIn').on('inview', function (event, visible) {
if (visible == true) {
// element is now visible in the viewport
$(this).removeClass("hidden");
$(this).addClass("visible animated bounceIn");
} else {
// element has gone out of viewport
$(this).removeClass("visible animated bounceIn");
$(this).addClass("hidden");
}
});
$('.anim_bounceInUp').on('inview', function (event, visible) {
if (visible == true) {
// element is now visible in the viewport
$("#"+$(this).attr("relID")).removeClass("hidden");
$("#"+$(this).attr("relID")).addClass("visible animated bounceInUp");
} else {
// element has gone out of viewport
$("#"+$(this).attr("relID")).removeClass("visible animated bounceInUp");
$("#"+$(this).attr("relID")).addClass("hidden");
}
});
});
据我所知,滚动时触发函数的效率不是很高。我有更好的方法来完成这个吗?
这是有问题的页面,它只是一个测试区域...
最佳答案
This readme说出你需要简单地捕捉 inview
不与 scroll
事件进行任何直接交互的事件。
此外,无论如何,如果您出于某种原因需要捕获 scroll
事件,则处理程序必须尽可能轻量级。例如,您应该将所有 jQuery
对象缓存在处理程序外部的全局变量中,而不是每次都调用构造函数。
关于javascript - JQuery/CSS 动画转换减慢页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39248752/
我正在使用 UISnapBehavior,但它的捕捉速度太快了,我不喜欢。有没有办法让它慢下来?或者换句话说:有没有办法用它应该捕捉的点来调整物体的弹性? 最佳答案 我能够通过将 View 附加到 U
我想减慢 SWTBot 的执行速度。 我已经找到了这个 wiki: https://wiki.eclipse.org/SWTBot/FAQ#Can_I_slow_down_the_execution_
我的应用程序中有一个计时错误,只有在我使用 valgrind 时才会发生,因为 valgrind 会大大减慢进程的速度。 (它实际上是一个我无法本地化的 boost::weak_ptr-excepti
问题 我正在创建一个涉及躲避射弹的游戏。玩家控制着一艘船的图像,我不希望船完全一起移动,因为这看起来非常不现实。 问题 有没有办法控制图像移动的速度,如何减慢图像的移动速度? 代码 var game
我在我的 iOS 应用程序中使用了 NSTimer,但由于 SetNeedsDisplay,我没有得到我想要的结果。 我做了一些研究并找到了 CADisplayLink,它为我提供了我想要的动画结果。
我目前正在开发一个项目,当按下按钮时,该项目会将圆从一个空间移动到另一个空间。我的设计如下:当按下按钮时,它会在 for 循环中从 0 到 10 增加圆的坐标。 问题是,我想要的 for 循环运动没有
我想缓慢地制作一个三色渐变动画。 我有一个自定义UIView,如下所示: class MyView: UIView, CAAnimationDelegate { lazy var gradient
当 RAM 达到 x 内存量或调用 didReceiveMemoryWarning() 时,是否有办法减慢处理器速度? func didReceiveMemoryWarning() { sup
有没有办法减慢行插入/删除动画的速度? 在我的特殊情况下,我通过在我的单元格下方添加/删除行来扩展/折叠单元格,我想稍微放慢动画速度。 最佳答案 我正在使用以下技巧在我的项目中以动画方式插入/删除表格
我的 Logo 和页脚中有 scroll-top 属性,但我离页面顶部越远,它向上滚动的速度就越快!所以当我从页面底部滚动到顶部时,它就像火箭一样!我将如何放慢速度?我找不到足够具体的答案 可以看看l
我想放慢由我的 UIDynamicAnimator 生成的动画,以便我可以微调我的 UIDynamicBehaviors。 在 ios 模拟器中,调试菜单下有一个菜单选项,标签为“在最前面的应用程序中
在 OS X 上,可以按住 Shift 键使动画变慢。有什么方法可以通过远程调试器或 Instruments 将其应用于 iOS 吗? (或者,我可以在 QuickTime 中录制并逐帧回放,但我宁愿
我想在 .opacity CSS 属性中减慢动画时间。就像,我希望它延迟 0.2 毫秒或类似的东西。 为了获得更好的想法,将鼠标悬停在我网站上的精选帖子上时会添加不透明度:http://www.the
我希望我的 UIPageViewController 在用户的手指离开屏幕时缓慢滚动到下一页。比默认情况下慢。如果可能的话,对其减速曲线等进行更多控制。 我不想使用 SCPageViewControl
我发现了这个 javascript 自动滚动函数,并通过将其粘贴到 WordPress 站点的头文件中来使其工作。但是,我想减慢滚动速度,以便它不会立即捕捉到页面底部。 我是 javascript 的
我正在使用 UIScrollView 以编程方式为某些内容设置动画。 但是,我需要减慢 View 的滚动速度。 这是我用于滚动的代码: self.scrollView.setContentOffset
我一直在使用 jQuery 滚动来增强我的视差滚动页面。具体来说就是这个。 JQuery Scroll to Next Section 我对 jQuery 完全陌生(过去只使用过一些相当基本的 Jav
如何减慢 Windows 进程? 我知道我需要 Hook QueryPerformanceCounter 但接下来我需要做什么? 需要 Delphi 或 C++ 方面的帮助 最佳答案 我不确定我是否理
我想在我这边控制下载量/速度——在服务器端也一样(礼貌一点)。...不是“我自己的下载管理器”。 让我们想象一下:我允许我的儿子每天从 utube 下载最多 500Mb,但他仍然启动了一个 sessi
在我的网站上,我有多个 href's,我需要在点击它们和加载它们之间添加延迟。由于有数百个 hrefs,我不能为每个单独的 js 函数。 我研究过的两种方法是,将 href 的内容作为变量传递给 ja
我是一名优秀的程序员,十分优秀!