简体   繁体   English

视口大小不正确,导致动画无法滚动显示

[英]Incorrect viewport size causing animations to not excute on scroll

Note: This has been solved. 注意:此问题已解决。 Look at the bottom of this post for the fix. 查看此帖子的底部以获取修复。

I have this bizarre issue that I've pulling my hair out over for the past few days. 我有一个奇怪的问题,那就是过去几天我一直在梳头。 Thankfully I think I've isolated it to an issue with incorrect window / document heights causing my scroll animations to never appear. 值得庆幸的是,我认为我已经将其隔离到窗口/文档高度不正确的问题,导致我的滚动动画永远不会出现。 I'm trying to use the lightSpeedIn animation from animate.css to animate a h2 header in, but wow.js will simply hide the element and never reveal it despite scrolling past it. 我正在尝试使用animate.css中的lightSpeedIn动画来为其中的h2标头设置动画,但是wow.js只会隐藏该元素,尽管滚动了它也从不显示它。 If I remove wow.js and use only Animate.css the h2 title will animate just fine. 如果删除wow.js并仅使用Animate.css,则h2标题将具有动画效果。

I've done some debugging using the following code and I think I know why wow.js (I've also attempted using other scrolling libraries without success) is breaking - for some reason jQuery is reporting both the window height and document height to be 943. There's clearly a scroll bar on the website, so I'm pretty sure any scroll implementation I do won't work because the code never sees anything to scroll to. 我已经使用以下代码进行了一些调试,我想我知道为什么wow.js(我也曾尝试使用其他滚动库但未成功)被破坏-出于某种原因,jQuery报告窗口高度和文档高度都达到了943.网站上显然有一个滚动条,所以我很确定我做的任何滚动实现都不起作用,因为代码永远看不到要滚动的内容。

  <div id="console">
    $(window).height() = <span id="winheight"></span> <br/>
    $(document).height() = <span id="docheight"></span>
</div>

Will result in the following appearing on the website. 将导致以下内容出现在网站上。

在此处输入图片说明

Implementation with wow.js - doesn't work 用wow.js实施-不起作用

<h2 class="section-heading text-center wow lightSpeedIn">Sputnik Fact Sheet</h2>

In this case wow.js seems to be assiging the following style to the header, but it never seems to be toggled. 在这种情况下,wow.js似乎在将以下样式辅助至标题,但似乎从未切换过。

visibility: hidden; animation-name: none

Implementation with only animate.css - works 仅使用animate.css实现-作品

<h2 class="section-heading text-center animated lightSpeedIn">Sputnik Fact Sheet</h2>

The strangest fact about this is that the problem only occurs on one part of the website - I've got wow.js working just fine on other parts. 关于此的最奇怪的事实是,问题仅发生在网站的一部分上-我的wow.js在其他部分上也正常工作。 Some digging with firebug revealed that animation "lightSpeedIn" doesn't exist when it does. 一些关于萤火虫的挖掘发现,动画“ lightSpeedIn”不存在。 I've even attempted copying and pasting animation names from other areas of the website (eg the legacy tab) into the h2 element but it'll always think the animation name doesn't exist. 我什至尝试将网站其他区域(例如,旧版标签)中的动画名称复制并粘贴到h2元素中,但始终会认为动画名称不存在。

wow.js问题-来自http://bengoodwin.com.au/sputnik/的实时示例

I'm stumped as to how to go about fixing this. 我对如何解决此问题感到困惑。 Anyone have any insight into my issue? 有人对我的问题有任何见解吗? You can view a live demonstration of this problem here . 您可以在此处查看有关此问题的现场演示。

UPDATE 1: I thought this might have been a plugin/library incompatibility, so I removed everything but animate.css and wow.js - didn't fix anything. 更新1:我以为这可能是插件/库不兼容,所以我删除了animate.css和wow.js之外的所有内容,但没有解决任何问题。 I'm completely stumped. 我完全迷住了。

UPDATE 2: Attempted using other scroll libraries. 更新2:尝试使用其他滚动库。 They don't work either. 他们也不工作。 Narrowed it down to a possible issue with content being "invisible" to the viewport. 将其范围缩小到可能导致视口“看不见”的问题。

UPDATE 3: Found the solution . 更新3: 找到了解决方案 It was super simple - I had overflow-x: hidden on my html,body selector. 这非常简单-我有溢出-x:隐藏html,body选择器中。 I removed it and now the wow.js script works correctly. 我删除了它,现在wow.js脚本可以正常工作。

Found the solution. 找到了解决方案。 It was super simple - I had overflow-x: hidden on my html,body selector. 这非常简单-我有溢出-x:隐藏在html,body选择器中。 I removed it and now the wow.js script works correctly. 我删除了它,现在wow.js脚本可以正常工作。

Previous CSS Code 以前的CSS代码

html,body {
    height: 100% !important;
    margin: 0;
    background-color: #161519;
    color: #fffafa;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    font-size: 14.5px;
    line-height: 1.42857;
    max-width: 100%;
    overflow-x: hidden
}

Fixed CSS Code 固定的CSS代码

html,body {
    height: 100% !important;
    margin: 0;
    background-color: #161519;
    color: #fffafa;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    font-size: 14.5px;
    line-height: 1.42857;
    max-width: 100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM