如何创建函数序列?
我尝试这样做
myfun(params,
function(){
//something happen
}
);
,但它不起作用,我完全不知道为什么,我快要疯了。 几周后我仍然在思考一个问题,我真的需要帮助,因为我不太擅长 Jquery 语法。
我想要实现的是: 启动一个函数来检查您是否悬停在圆形区域内,如果确实悬停,则触发一系列函数,一个接一个(在本例中显示一系列动画)。而且我无法做出“一个接一个”。
我正在尝试这样做,因为在 safari 中,当您使用半径边框创建圆形链接时,并且您想要将鼠标悬停在元素上,它仍然表现为正方形。我不想使用图像映射。
同样,我无法重复使用相同的函数来多次检查圆形区域内的悬停(不要问我为什么,我试图理解,但我不够聪明或无法理解),所以我唯一的最后资源它是尝试根据序列触发事件。
aniCircle 它是我想要嵌套动画序列的函数。这是它看起来如何的功能:
$("#cv").hover(
function(){
$("#sliders .circle").css("z-index","6");
aniCircle(1, $(this), "#slider1", {"opacity":"0"},{"opacity":"1"}, 0, speed2,
function(){$("#slider2").delay(speed2).animate({"opacity":"1"},speed2)}
);
},
function(){
$("#slider1").animate({"opacity":"0"},speed2)
$("#slider2").delay(speed2).animate({"opacity":"0"},speed2)
}
);
这里有网页 http://life-is-simple.co.uk/test5/index.html
请记住,在 FF4 上它在圆形区域上工作正常,但在 webkit 浏览器上则不然,我想使用 JS 修复它。
感谢您的帮助
I tried to do
myfun(params,
function(){
//something happen
}
);
but it is not working, and I absolutely do not know why, and I am going crazy.
I am still banging my head on a problem after several weeks, and I need really an help because I am not so good at Jquery syntax.
What I am trying to achieve is:
Starting a function that check if you are hovering inside a circle area, if you do than trigger a sequence of function, one after another (in this case showing a series of animation). And I cannot make "one after another".
I am trying to do this, because in safari when you make a link round with radius-border, and you want to hover on the element, it still behave as a square. And I would like not to use image-maps.
As well I cannot re-use the same function to check the hovering inside a circle area more than once (do not ask me why, I tried to understand but I am not clever enough or able enough to comprehend), so my only last resource it is to try to trigger an event based on a sequence.
aniCircle it is the function where I want to nest my sequences of animations. This it is how does it look the function:
$("#cv").hover(
function(){
$("#sliders .circle").css("z-index","6");
aniCircle(1, $(this), "#slider1", {"opacity":"0"},{"opacity":"1"}, 0, speed2,
function(){$("#slider2").delay(speed2).animate({"opacity":"1"},speed2)}
);
},
function(){
$("#slider1").animate({"opacity":"0"},speed2)
$("#slider2").delay(speed2).animate({"opacity":"0"},speed2)
}
);
Here there is the webpage
http://life-is-simple.co.uk/test5/index.html
Remember on FF4 it works fine the circle area, it is on webkit browser that it doesn't and I want to fix it using JS.
Thank you for all your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我认为使用 jquery
.queue()
可以解决您的问题。I think using jquery
.queue()
can resolve your problem.jQuery animate() 接受“完整”回调。您可以像这样嵌套序列:
在 slider1 动画完成之前,slider2 动画不会开始。
jQuery animate() takes a "complete" callback. You can nest the sequence like:
The slider2 animation will not begin until the slider1 animation is complete.
看起来您正在尝试类似的操作:
注意方法声明后面的“()”,它会立即触发。
这些将一个接一个地触发,但如果您向它们应用将异步触发的代码,那么您将需要使用回调方法。
It looks like you are trying something like:
Notice the '()' after the method declaration which makes it fire immediately.
These will fire one after the other, but if you apply code to them that will fire asynchronously, then you will need to use a callback method.
默认情况下,JavaScript 没有“函数序列”。 jQuery 的 animate() 可以处理回调函数,因为它被编码为在动画完成时调用回调函数。
我认为你正在寻找类似的东西:
如果你正在做一些更复杂的事情,例如多级回调,你可能需要使用 jQuery 的 队列()。
JavaScript does not have "function sequences" by default. jQuery's animate() can handle callback functions because it's coded to call the callback function when the animation is complete.
I think you're looking for something like:
If you're doing something more complicated, e.g. multiple levels of callbacks, you may want to use jQuery's queue().
很抱歉,但我必须在以后重新提出这个问题,我注意到没有一个更简单的例子,也没有时间致力于我的网站(我发现自己整个星期都在忙于各种项目,甚至在正常之后工作时间),我不想仅仅为了保持开放而不尝试和测试您建议的解决方案而开放我的问题。
我很抱歉让您在这个问题上浪费了时间。今后我会努力做得更好。非常感谢您抽出时间。
我试图关闭它,但由于赏金,我无法关闭它:(
I am sorry but I have to remake the question later on in the future, I noticed that without a more straightforward example, and without having time to dedicate to my website (I found myself fairly busy on various projects all week long and even after normal working hours), I do not want to keep my question open just for the sake of keeping open without trying and testing your solutions suggested.
I am sorry for the losing time that I have made you spent on this question. I'll try to be better organised in the future. Thank you very much for your time.
I tried to closed it, but couse of the bounty I cannot close it :(