0
我遇到了jQuery代码的问题,我希望得到一些帮助。当下一个和上一个按钮正常工作时,正确停止幻灯片放映似乎存在问题。这大概是我们完全忽略的东西,但我看不到什么。需要使用jQuery停止幻灯片显示的帮助
控制台中没有显示JavaScript错误。正在达到中断方法 - 有一点我有console.log调用在那里进行验证(清理出于演示原因)。
你的帮助是非常赞赏。
下面的代码是上一张/停止未来的功能/启动/:
if ($(settings.next).size()) {
$(settings.next).bind('click.scrollface', function (e) {
methods.interrupt.call($this);
methods.next.call($this);
});
}
if ($(settings.pause).size()) {
$(settings.pause).bind('click.scrollface', function (e) {
methods.interrupt.call($this);
});
}
if ($(settings.play).size()) {
$(settings.play).bind('click.scrollface', function (e) {
methods.interrupt.call($this);
methods.start.call($this);
});
}
/*
* Setup up prev bindings
*/
if ($(settings.prev).size()) {
$(settings.prev).bind('click.scrollface', function (e) {
methods.interrupt.call($this);
methods.prev.call($this);
});
}
下面是中断的方法:
interrupt: function (time) {
return $(this).each(function() {
var data = $(this).data('scrollface');
console.log(data);
console.log('...');
if (!data) {
return false;
}
var $this = $(this),
period = 0;
/*
* Stop the timer, and wait a period of time before restarting it.
* Period defaults to the timer interval
*/
if (data.timer) {
if (typeof time !== "number") {
period = data.interval;
} else {
period = time;
}
methods.stop.call(this);
setTimeout(function resume_timer() {
clearInterval(data.timer);
data.timer = null;
methods.start.call($this);
}, period);
}
});
},
你得到一个错误?你的问题不清楚哪里出了问题。 – DLeh 2015-02-06 15:30:34
嗨DLeh,没有任何错误。它实际上是运行中断方法 - 这是来自jQuery的scrollface库 - 但未能停止实际的幻灯片。 – 2015-02-06 17:23:31
@WSTeam我怀疑这里的评论意味着你的问题。在jquery.scrollface.js中*/* *停止计时器,并等待一段时间再重新启动计时器。 *周期默认为定时器间隔 * /'请参阅,您注意到它仅在短时间内中断sildshow。所以暂停和停止不一样。它真的停了片刻。而是调用'stop' – 2015-02-06 17:42:57