简体   繁体   English

如何在Foundation 4 Orbit中捕获滑块事件?

[英]How to capture slider events in Foundation 4 Orbit?

I want my page to change some elements with each slide in the slider. 我希望页面在滑块中的每张幻灯片上更改一些元素。 I managed to do this in the desktop version, by attaching functions to the click events, like this: 我设法通过将功能附加到click事件来在桌面版本中做到这一点,如下所示:

$(".orbit-next").on("click", nextChange);
$(".orbit-prev").on("click", prevChange);

But that doesn't work in the touch slide version :( Does anyone know how to achieve this? I couldn't find any event related to the touch slide, neither any function to call. 但这在触摸幻灯片版本中不起作用:(有人知道如何实现吗?我找不到与触摸幻灯片相关的任何事件,也找不到任何要调用的函数。

Have a look in the 'foundation.orbit.js', you can see the events that it uses. 看看“ foundation.orbit.js”,您可以看到它使用的事件。

'orbit:after-slide-change.fndtn.orbit'
'orbit:next-slide.fndtn.orbit click.fndtn.orbit'
'orbit:prev-slide.fndtn.orbit click.fndtn.orbit'
'orbit:toggle-play-pause.fndtn.orbit click.fndtn.orbit touchstart.fndtn.orbit' 
'touchstart.fndtn.orbit'
'touchmove.fndtn.orbit'
'touchend.fndtn.orbit'

You can listen to these using jQuery bind on the element used by orbit. 您可以在轨道使用的元素上使用jQuery 绑定来收听这些内容。

$("[data-orbit]").bind('orbit:after-slide-change.fndtn.orbit', function(event){
      console.log('slide change', event);
      //alert('slide change', event);

      //do clever stuff
    });

The 'after-slide-change.fndtn.orbit' is probably most useful as this should fire on all devices. “ after-slide-change.fndtn.orbit”可能最有用,因为它应该在所有设备上触发。 (I tested this in Chrome and on the iPad). (我在Chrome和iPad上对此进行了测试)。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM