- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我制作了一个 svg、css 动画并添加了一些 jquery 键盘事件。每当我按下按键时,动画就会一次又一次地开始。
有没有办法只在页面加载后播放动画?
滑动事件也不再有效(我之前用图像测试过它)
j查询:
$(document).ready(function(){
$(document).keyup(function(e) {
if (e.keyCode === 40) {
$(".arrow_down").animate({
top:"+=20px",
opacity:"0"
});
$(".button").animate({
opacity:"1"
});
}
if (e.keyCode === 37) {
$(".arrow_down").effect("bounce",{times:3}, 500 );
}
if (e.keyCode === 39) {
$(".arrow_down").effect("bounce",{times:3}, 500 );
}
if (e.keyCode === 38) {
$(".arrow_down").effect("bounce",{times:3}, 500 );
}
});
$(".arrow_down").swipe({
swipeDown:function(){
$(".arrow_down svg").animate({top:"+=5%", opacity:"0"});
$(".button").animate({opacity:"1"});
}
});
});
fiddle : http://jsfiddle.net/9KwLW/
最佳答案
好的;我想到了。这可能不是最优雅的解决方案,但我找不到更好的解决方案。
所以我将带有动画的类从“line”更改为“animline”。然后在 700 毫秒后,我搜索所有带有类“line”的项目并删除它们的类“animline”——我不能为此使用 jQuery,因为 jQuery 不能在没有任何插件的情况下搜索 SVG 中的元素,所以为什么不使用一些纯 JavaScript。
参见 fiddle : http://jsfiddle.net/9KwLW/2/
JS:
window.setTimeout(function(){
lines = document.getElementsByClassName('line');
for (i=0;i<lines.length;i++) {
lines[i].classList.remove("animline");
}
},700);
CSS:
.animline {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
-moz-animation: dash 5s linear forwards;
-webkit-animation: dash 5s linear forwards;
-moz-animation-timing-function: ease;
-webkit-animation-timing-function: ease;
}
HTML:
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="7px" height="193px" viewBox="0 0 7 193" enable-background="new 0 0 7 193" xml:space="preserve"><line class="line animline" fill="none" stroke="#000000" stroke-width="7" stroke-miterlimit="10" x1="3.5" y1="0" x2="3.5" y2="193"/>
</svg>
<svg class="arrow_head" version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"width="63.25px" height="36.75px" viewBox="0 0 63.25 36.75" enable-background="new 0 0 63.25 36.75" xml:space="preserve"><polyline class="line animline" fill="none" stroke="#000000" stroke-width="7" stroke-miterlimit="10" points="60.5,2.686 31.688,30.509 2.875,2.686 "/></svg>
关于javascript - 动画在 keyup 事件后重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24784080/
我创建了一个 keyup() 函数,代码在这里 $(document).ready(function() { var scntDiv = $('#add_words'); var wo
我希望它只在 keyup 而不是之前触发。有人可以帮忙吗? $(function() { $('#acf-field_5a32085c7df98-field_5a3208f87df99').on('k
在 Chrome 30.0.1599.101 和 IE 11 中,输入选择器无法在 Firefox 25.0.1 中正常工作 在 Chrome/IE 中损坏: $(document).ready(fu
在我为工作而构建的网站上,我们有一个搜索栏,用户可以在其中输入内容以搜索存储在一组元素数据中的各个字段。当他们开始输入时,问题出现在较慢的浏览器中。 我尝试做的是以下操作,使用 jQuery Defe
我正在尝试使用 vanilla js 编写一些简单的东西来在用户按下回车键时触发一个函数。我在下面找到了一些代码,但我不确定如何让它工作,因为该函数没有名称。 function (event) {
场景如下: 我有一个内容可编辑的 div。我还有一个文本区域,其中 .keyup() 上发生了一些事情。 我需要这样,在content editable div的keyup()上,将contented
有一个输入文本会在“onkeyup”事件上触发一个函数。当该函数触发时,我将使用 .on("keyup") 方法绑定(bind)一个“keyup”事件,以获取最后按下的键以查明它是否是字母数字,以便触
我想知道如何对同一个 #id 执行 .keyup() 和 .click() ? 即本质上,我想在用户尝试点击 enter 或点击 #search 按钮时验证 #id 。 非常感谢 最佳答案 $('#f
我必须在这里使用jquery keyup来检测用户是否输入任何文本,但我的问题是如果用户使用鼠标粘贴文本,它将无法检测到它,你能告诉我原因吗? 这是我的源代码: $("textarea").keyup
我正在尝试创建一个输入字段,用户只能在其中输入数字。这个功能对我来说已经可以正常工作了: $('#p_first').keyup(function(event){ if
我正在尝试编写类似于“占位符”polyfill 的内容。我想捕获输入字段上的 keyup 事件并获取用户输入的字符,所以我有以下代码: $elem.on('keyup',function(e){
我想我已经弄清楚了......请参阅我的评论。抱歉。 我有一个 JSON Web 服务,它在某个 keyup() 事件上调用,该事件根据输入检索一些数据。我想在输入任何内容之前加载一组初始数据。我正在
所以我使用 Keyup 来计算输入字段的总数。到目前为止,一切都很好。但现在我想这样做:如果选中#a 复选框,则将总金额加 12。如果没有,则添加 0。 我的代码基于此:http://jsfiddle
我在弄清楚为什么 keyup 事件在以下情况下不起作用(不显示警报)时遇到问题,我对表单使用 bootstrap 3,但我不认为 form-control取消键盘输入? HTML: jQuery:
我正在构建一个搜索表单,.keyup 中的 ajax 函数可以有不同的参数,我想通过检查是否存在另一个值来检查是否需要包含此参数。这是我现在拥有的: var delay = (function() {
我的 html 和 jquery 代码 Insert title here td { min-height: 50px; min-width: 50px; }
每次我按下键盘上的一个键,它都会将 $(this).val(""); 设置为 null,并且 score 变量将为 -2 . initialize: function() { var scor
我是 javascript 及其事件的新手。这是我的表格 html 代码,其中有收入标题及其各自的价格。 sn Title of income
我有一个这样的表: 当数量/价格变化小计也发生变化时,我想制作Javascript。我的js: $("#invoice_item").delega
我正在 js 中制作字符计数器,但 keyup 事件不起作用??? $(document).ready(function() { function countingCharacter(elemen
我是一名优秀的程序员,十分优秀!