我正在将JSSOR滑块用于网站上的多个图像。
我在幻灯片中的图像上添加了<a href="...
链接,该链接打开了一个花式框窗口以显示更大的版本。
问题在于,当您单击并拖动鼠标时,它会滑动图像,但由于发生单击事件,因此还会启动fancybox控件。
有没有办法阻止这种情况的发生?
码:
<?php
foreach($image as $img){
?>
<div>
<a u="image" class="fancybox" href="images/uploads/<?php echo($img); ?>">
<img u="image" style="width=auto;" src="images/uploads/<?php echo($img); ?>" />
</a>
</div>
<?php
}
?>
最佳答案
如果成功进行拖动操作,Jssor Slider将停止触发“ click”事件。但是我不确定花哨的盒子是否会在jssor滑块之前捕获'click'事件。
因此,请按照以下方式以编程方式打开您的精美框,
<script>
jQuery(document).ready(function ($) {
var options = {
$AutoPlay: true, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
$DragOrientation: 1 //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
};
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
function SliderClickEventHandler(slideIndex, event) {
//open fancy box
}
jssor_slider1.$On($JssorSlider$.$EVT_CLICK, SliderClickEventHandler);
});
</script>
关于jquery - 如何在不破坏幻灯片功能的情况下使JSSOR Slider具有可单击的图像?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28068816/