【问题标题】:How can I make JSSOR Slider have clickable images without breaking slide functionality?如何在不破坏幻灯片功能的情况下使 JSSOR Slider 具有可点击的图像?
【发布时间】:2015-01-21 13:47:54
【问题描述】:

我正在为网站上的多个图像使用 JSSOR 滑块。

我在幻灯片中的图片上添加了一个<a href="... 链接,它会打开一个fancybox 窗口来显示更大的版本。

问题是当你点击并拖动鼠标时,它会滑动图片,但也会触发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 滑块中拖动链接,它不会触发点击事件。请在此处发布您的代码。
  • 我采用了带有基本示例代码的滑块,并在 img 周围添加了&lt;a href=...
  • Jssor,我在上面添加了我的代码,我可以看到它适用于基本链接,但不能使用 fancybox 控件。

标签: jquery jssor


【解决方案1】:

如果拖动操作成功,Jssor Slider 将停止触发 'click' 事件。但我不确定花哨的盒子是否会在 jssor 滑块之前捕获“点击”事件。

所以,请以以下方式以编程方式打开您的花哨的盒子,

<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> 

【讨论】:

  • 我可以看到这是如何工作的,我遇到的麻烦是我需要将图像源解析为fancybox控件。这可能吗?
  • 可以通过参数'slideIndex'判断图片来源
  • 我在我的 asp.net Web 应用程序中使用 jssor 滑块。我尝试在滑块的图像周围添加
猜你喜欢
  • 2014-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-07
  • 1970-01-01
  • 1970-01-01
  • 2015-12-01
相关资源
最近更新 更多