jQuery Cycle - 动态更改选项
问题:
如何通过 HTML 元素上的鼠标交互异步更改 jQuery Cycle 的选项?
jsFiddle
这是一个工作示例。 请参阅评论以澄清意图
进行的研究:
这个来自cycle作者的推文揭示了可以异步修改cycle的选项。
我在后续推文中问他是否可以详细阐述这个主题,他说(释义)“继续潜伏”。
检查了cycle的源代码后,我发现他没有说谎。 cycle.opts
确实存在,而且还有一个 debug
函数,显然有一些值得注意的用途。然而,我对如何利用这些功能知之甚少。
我可以使用 Cycle.opts 返回对象的状态,但这是“...然后更改您需要的内容”,这是我无法弄清楚的方面。我已经查看了选项参考页面,并且其他选项的默认值没有出现就像他们会干涉一样。
Question:
How would I change jQuery Cycle's options asynchronously via mouse interactions on HTML elements?
jsFiddle
Here's a working example. Refer to the comments for clarification on intentions
Conducted Research:
This tweet from cycle's author reveals that it's possible to modify cycle's options asynchronously.
I asked him in a follow-up tweet if he could expound on the subject and he said (paraphrasing) "keep lurking."
After examining cycle's source code, I found that he wasn't lying. cycle.opts
, indeed, exists, and there's also a debug
function that's apparently of some mentionable use. However, I have very little idea on utilizing these features.
I can return the state of the object using cycle.opts
, but it's the "...and then change what you need," aspect that I can't figure out. I've reviewed the Options Reference page and the defaults from the other options don't appear like they would interfere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,除非我遗漏了什么,否则您根本不会更改代码中的选项。试试这个:
Well, unless I'm missing something, you're not changing the options at all in your code. Try this:
使用您的方法,在初始设置后无法动态更改悬停暂停行为。下面发布了解决方法代码。
根据您问题中的 jsFiddle 示例,我无法使其正常工作。
就我而言,我希望幻灯片像往常一样循环播放,但在用户第一次单击图像后激活悬停行为的暂停。
经过一些调试后,我想动态更改的特定选项(即“pause”和“pauseOnPagerHover”)似乎在第一次设置幻灯片后将不再适用。
在没有找到实际原因的情况下,我为我的问题编写了一个可行的解决方案,如下:
这是一个 jsFiddle< /a> 演示上面的代码。
With your method, pause-on-hover behavior can't be changed dynamically after initial setup. Workaround code is posted below.
I could not get this to work based on the jsFiddle example in your question.
In my case, I wanted the slideshow to cycle as usual, but activating the pause on hover behavior after the user clicks an image the first time.
After some debugging it seems like the specific options I wanted to change dynamically, namely 'pause' and 'pauseOnPagerHover', won't apply after having set up the slideshow the first time.
Without having found out the actual reason for this, I hacked together a working solution to my problem, below:
Here's a jsFiddle demonstrating the code above.