【问题标题】:Fotorama Slider: How can I get the slider to pause on mouse over the resume auto play when mouse out?Fotorama 滑块:如何让滑块在鼠标悬停时暂停在恢复自动播放上?
【发布时间】:2013-10-12 13:55:16
【问题描述】:

Fotorama 滑块:滑块设置为 Autoplay="true",效果很好。如何让滑块在鼠标悬停时暂停,然后在鼠标移出时恢复自动播放?这是我的代码:

<div class="fotorama" data-width="1170" data-ratio="1170/374" 
     data-max-width="100%" data-autoplay="true" data-autoplay="3000" 
     data-stopautoplayontouch="false">

【问题讨论】:

  • 如果我将 data-stopautoplayontouch="false" 设置为 "true",滑块将在鼠标悬停时暂停,但不会在鼠标移出时恢复。

标签: jquery slider mouseover autoplay fotorama


【解决方案1】:
var $fotorama = $('.fotorama'),
    interval = $fotorama.data('autoplay'),
    fotorama = $fotorama.data('fotorama');

$fotorama.hover(
    function () {
        fotorama.stopAutoplay();
    },
    function () {
        fotorama.startAutoplay(interval);
    }
);

小提琴:http://jsfiddle.net/aha3xLsy/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多