- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 CSS 动画和 jQuery 在日历上打开多个翻盖。只要用户等待动画结束然后单击下一个动画,它就可以很好地工作。但是当打开动画仍在运行时,用户已经开始下一个动画,脚本中断并且我的类 opend
从 .fenster
div 和 window 中删除布局。
有人看到我的脚本哪里有问题吗?
$( document ).on("click" , '.flap' , function(){
if ($(this).parent(".fenster").hasClass("opend")) {
$(this).removeClass("flap_open" ).addClass("flap_close" );
$(this).one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
$(this).next().hide();
$(this).removeClass("flap_close");
$(this).parent(".fenster").removeClass("opend");
});
} else {
$(this).addClass("flap_open" );
$(this).parent(".fenster").addClass("opend");
//$(this).removeClass("flap_close" );
$(this).next().show();
}
});
.fenster {
width: 30%;
min-width: 130px;
max-width: 300px;
border: 1px solid rgba(212, 212, 212, 1);
position: relative;
left: 200px;
z-index: 200;
cursor: pointer;
}
.opend {
perspective: 1500px;
-webkit-perspective: 1500px;
box-shadow: inset 0px 0px 5px #2e2d2e;
cursor: auto;
-webkit-backface-visibility: hidden;
}
.flap {
width: 100%;
height: 100%;
z-index: 100;
background-color: red;
}
.flap:before {
content: "";
display: block;
padding-top: 75%;
}
.flap_open {
transform-origin: 0 50%;
-webkit-transform-origin: 0 50%;
background-size: cover;
width: 100%;
height: 100%;
z-index: 100;
cursor: alias;
animation: turn 4s forwards;
-webkit-animation: turn 4s forwards;
box-shadow: 5px 0px 5px 0px #2e2d2e;
}
.flap_close {
transform-origin: 0 50%;
-webkit-transform-origin: 0 50%;
-webkit-animation: zumachen 4s forwards;
animation: zumachen 4s forwards;
opacity: 0.8;
box-shadow: 5px 0px 5px 0px #2e2d2e;
transform: rotateY(-100deg);
}
.button{
position: absolute;
bottom: 2%;
left: 15%;
width: 70%;
height: 5vh;
min-width: 80px;
min-height: 28px;
max-height: 20px;
z-index: -1;
text-align: center;
display: table;
background-color: grey;
}
@keyframes turn {
to {
transform: rotateY(-100deg);
opacity: 0.8;
box-shadow: 5px 0px 5px 0px #2e2d2e;
visibility: visible;
}
}
@-webkit-keyframes turn {
to {
-webkit-transform: rotateY(-100deg);
-webkit-opacity: 0.8;
box-shadow: 5px 0px 5px 0px #2e2d2e;
visibility: visible;
}
}
@keyframes zumachen {
to {
transform: rotateY(0deg);
opacity: 1;
box-shadow: none;
visibility: visible;
}
}
@-webkit-keyframes zumachen {
to {
-webkit-transform: rotateY(0deg);
-webkit-opacity: 1;
box-shadow: none;
visibility: visible;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fenster f7 p3">
<div class="flap"></div>
<div class="button" style="display: none;"><span>Something</span></div>
</div>
<div class="fenster f3 p1">
<div class="flap"></div>
<div class="button" style="display: none;"><span>Something</span></div>
</div>
最佳答案
如果添加一个指示动画正在运行的类,则可以运行检查以确保任何当前动画元素不会受到在任何关闭时调用的 .removeClass()
方法的影响元素。
.one()
方法到您初始的 else
代码块条件语句你可以再次删除这个前面提到的类一旦动画完成.one()
方法中插入另一个条件检查您的初始条件检查以验证中的元素问题没有类 .animation-running
,因此表明它应该删除必要的类。$(document).on("click", ".flap", function() {
if ($(this).parent(".fenster").hasClass("opend")) {
$(this).removeClass("flap_open").addClass("flap_close");
$(this).one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
if (!$(this).parent(".fenster").hasClass("animation-running")) {
/* only step into next code block if condition is equal to true,
* i.e: parent does not have the class "animation-running", so animation is completed
*/
$(this).next().hide();
$(this).removeClass("flap_close");
$(this).parent(".fenster").removeClass("opend");
}
});
} else {
$(this).addClass("flap_open");
$(this).parent(".fenster").addClass("opend animation-running"); /* Additional class to indicate animation is running */
$(this).next().show();
/* Only once animation has completed should the indicating class be removed */
$(this).one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
$(this).parent(".fenster").removeClass("animation-running");
});
}
});
.fenster {
width: 30%;
min-width: 130px;
max-width: 300px;
border: 1px solid rgba(212, 212, 212, 1);
position: relative;
left: 200px;
z-index: 200;
cursor: pointer;
}
.opend {
perspective: 1500px;
-webkit-perspective: 1500px;
box-shadow: inset 0px 0px 5px #2e2d2e;
cursor: auto;
-webkit-backface-visibility: hidden;
}
.flap {
width: 100%;
height: 100%;
z-index: 100;
background-color: red;
}
.flap:before {
content: "";
display: block;
padding-top: 75%;
}
.flap_open {
transform-origin: 0 50%;
-webkit-transform-origin: 0 50%;
background-size: cover;
width: 100%;
height: 100%;
z-index: 100;
cursor: alias;
animation: turn 4s forwards;
-webkit-animation: turn 4s forwards;
box-shadow: 5px 0px 5px 0px #2e2d2e;
}
.flap_close {
transform-origin: 0 50%;
-webkit-transform-origin: 0 50%;
-webkit-animation: zumachen 4s forwards;
animation: zumachen 4s forwards;
opacity: 0.8;
box-shadow: 5px 0px 5px 0px #2e2d2e;
transform: rotateY(-100deg);
}
.button {
position: absolute;
bottom: 2%;
left: 15%;
width: 70%;
height: 5vh;
min-width: 80px;
min-height: 28px;
max-height: 20px;
z-index: -1;
text-align: center;
display: table;
background-color: grey;
}
@keyframes turn {
to {
transform: rotateY(-100deg);
opacity: 0.8;
box-shadow: 5px 0px 5px 0px #2e2d2e;
visibility: visible;
}
}
@-webkit-keyframes turn {
to {
-webkit-transform: rotateY(-100deg);
-webkit-opacity: 0.8;
box-shadow: 5px 0px 5px 0px #2e2d2e;
visibility: visible;
}
}
@keyframes zumachen {
to {
transform: rotateY(0deg);
opacity: 1;
box-shadow: none;
visibility: visible;
}
}
@-webkit-keyframes zumachen {
to {
-webkit-transform: rotateY(0deg);
-webkit-opacity: 1;
box-shadow: none;
visibility: visible;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fenster f7 p3">
<div class="flap"></div>
<div class="button" style="display: none;"><span>Something</span></div>
</div>
<div class="fenster f3 p1">
<div class="flap"></div>
<div class="button" style="display: none;"><span>Something</span></div>
</div>
关于javascript - jquery (this).parent.hasClass 在动画中给出误报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47324518/
import lombok.Data; @Data public class Filter { private Operator operator; private Object va
我刚刚在 SonarQube 中发现了一个误导性问题,我们的代码如下(JS) {…} function test(searchQuery, role) { console.log("inputs: "
我想我发现了误报: const items = document.querySelectorAll(selectors); for (const item of items) { if(item)
这是我第一次尝试编写实现简单形式的堆栈跟踪的自定义异常类。 这是.h: class error { public: error (); error (const
我正在尝试构建我的第一个 XML 模式 validator 作为我的代码库和许多项目中的可重用组件。我花了一整天的时间尝试遵循示例并对其进行编码,现在已经启动并运行了概念验证。 唯一的问题是,它给了我
我的数据库中有一个表,其中有一个名为“tags”的字段,例如iOS、Android、Java、JavaScript 等。我想选择此表中的所有项目,这些项目与某些标签相匹配,例如 id | name |
我刚刚开始在一个现有的中型项目中试验 .NET 4 中的 CodeContracts,令我惊讶的是静态检查器向我发出有关以下代码片段的编译时警告: public class Foo { priv
我不知道为什么,但我以前没有问题,现在突然之间,我很久以前写的这个非常古老、可怕的新手程序触发了 Malwarebytes... :( 这个问题不是重复的,因为有问题的程序是在 (ANSI) C 而不
在 Ubuntu 9.10 下启动了一个 Git 存储库。终于升级到10.04。当前的 Git 是 1.7.0.4。 现在,当我编辑升级前最后更改的文件(使用 gedit)然后提交时,提交中充满了误报
在设置 mod_security 后,我收到了很多误报 [??]。我只是在检测中运行它,所以还没有问题,但是一旦我需要它上线,这些过滤器就会开始阻止请求。 恐怕我不能 100% 理解这些过滤器的重要性
引用 Valgrind 教程: Optimized code can cause valgrind to wrongly report uninitialized value errors. The
Sonar 是否有可能在分支之间传输“误报”? 这是我们的工作流程:我们在分支 1 中进行开发,我们对此分支进行 Sonar 检查,当分支 1 发布时,我们将其合并到主干中,然后我们从主干创建分支 2
我的代码库中有一个静态函数的实现,并且在运行 clang-tidy 时在它上面,我注意到当我很确定代码正确时,静态分析器指向可能的内存泄漏。 (我已经用 sanitizer 验证过)。我认为这很可能是
Coverity 标记了一个我无法理解的问题。 我有一个初始化器: 1686 arrayOfNodeIds componentRefs = (arrayOfNodeIds) { 1687 .s
react.js 发生了一些奇怪的事情 Top-Level API . 这是我的mocha 测试的摘录: it.only('should identify a ReactElement', funct
大家好,我在使用 Apple 的可达性代码时遇到了一些问题。我发现,即使设备正确连接到互联网,最初可达性代码也会发出 1 个错误通知(Networkstatus = NotReachable),然后是
我一直在尝试运行 Insure++使用一些科学代码并报告许多错误,尽管公平地说它正式不支持 K&R C,而且我不知道大量 K&R 函数对其评估过程有何影响。它正在测试的 C 和 C++ 代码正在从 W
当我尝试调用 CFileFind.FindFile(_T("D://Folder//*.txt")) 时,当唯一的文件是“foobar.txta”时,该方法返回 true . 但是,我不希望文件 fo
在我之前的问题 ( "Pylint E0202 False Positive?" ) 之后,这里是另一个问题(我想很具体) 我们正在使用模块子流程来执行子流程。 创建示例代码会产生以下结果: "Exa
我有一个包含 2,865,044 个条目和 3 级 MultiIndex 的数据框 MultiIndex.levels.names = ['year', 'country', 'productcode
我是一名优秀的程序员,十分优秀!