featherlight gallery触摸示例

时间:2015-10-02 09:39:04

标签: jquery-mobile touch swipe featherlight.js

请向我展示使用触摸库启用滑动(导航图像)的羽毛灯的示例。

根据网站 https://github.com/noelboss/featherlight/wiki/Gallery:-swipe-on-touch-devices 支持启用触摸的三个库:

  • jQuery Mobile
  • jQuery detectSwipe
  • jQuery Mobile events

寻求一个示例,展示如何在羽毛灯中使用其中任何一个。

  • 我不需要另一个库,因为它已经在使用了。

2 个答案:

答案 0 :(得分:2)

经过一番搜索并试图找到一个例子后,我找到了答案。

featherlight.js的文档不是很清楚,但它只是答案。只需在包含featherlight.js之前包含swipe_detec.js,它就会在移动设备上启用触摸功能。

例如

    <html>
    <head>
    <!-- jquery -->
     <script src="//code.jquery.com/jquery-latest.js"></script>

    <!-- featherlight -->
        <script src="//cdnjs.cloudflare.com/ajax/libs/detect_swipe/2.1.1/jquery.detect_swipe.min.js"></script>
        <link href="//cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.min.css" type="text/css" rel="stylesheet" />
        <script src="//cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.min.js" type="text/javascript" charset="utf-8"></script>

<!-- featherlight gallery -->

<link href="//cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.gallery.min.css" type="text/css" rel="stylesheet" />
<script src="//cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.gallery.min.js" type="text/javascript"></script>
</head>

    <body>  
<a class="thumbnail gallery" href="a.jpg" > <img src="a.jpg" /> </a>
<a class="thumbnail gallery" href="b.jpg" > <img src="b.jpg" /> </a>
<a class="thumbnail gallery" href="c.jpg" > <img src="c.jpg" /> </a>

    <script>
    $(document).ready(function(){
        $('.gallery').featherlightGallery();
    });
    </script>
    </body>
    </html>

希望有人发现它有用。

答案 1 :(得分:0)

感谢@Hussain,这很有效,只有一点点奇怪的是灯箱下方的页面也响应了阻力。 该示例可以更新到更高版本的脚本,例如:

def next(I):

if I == 0:
    return 0
else:
    s_I = str(I)
    result_s = ''
    result_i = 0
    while True:

        if len(s_I) !=0:
            count = 1
            marker = s_I[0]
            for x in range(0, (len(s_I)-1)):
                if s_I[x] == s_I[x+1] and s_I[x] == marker:
                    count = count + 1
            result_s = result_s + str(count) + marker

            s_I = s_I[count:]
            continue
        else:
            break

    result_i = int(result_s)
    print(result_i)