jQuery Unslide-触摸不起作用 [英] jQuery Unslide - Touch doesn't work

查看:72
本文介绍了jQuery Unslide-触摸不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经解决了这个问题,我只是在发布帖子以帮助他人节省一些时间.

我在商业网站上使用unslider,而我正在对此网站进行响应,因此向滑块添加触摸支持的功能很吸引人.不幸的是,正如作者声称的那样,它不能立即使用.

解决方案

更新
我使用的unslider插件已过时.我从unslider.com上找到它的地方下载了该文件(那里仍然是过时的版本),因此遇到了麻烦.

如果需要获取最新版本,请访问: https://github.com/idiot/unslider/

如果您想查看我的问题报告: https://github.com/idiot/unslider/issues/69


问题在于作者在4个月内没有更新项目,此后,滑动事件已从$ .event.swipe移至$ .event.special.swipe.

问题发生在unslider插件的第108行,它在其中测试了swipe插件的存在.

108: if($.event.swipe) {
109:    this.el.on('swipeleft', _.prev).on('swiperight', _.next);

只需将其更改为:

108: if($.event.special.swipe) {
109:    this.el.on('swipeleft', _.prev).on('swiperight', _.next);

这是一个简单的解决方法,但需要花一些时间来弄清楚.

如果要确保它可以在早期版本中使用,可以执行以下操作:

108: if($.event.special.swipe || $.event.special.swipe) {
109:    this.el.on('swipeleft', _.prev).on('swiperight', _.next);

但我不建议这样做.

,作者没有提及,但是滑动插件页面确实提到了,除了在脚本中包含jquery.event.swipe之外,您还需要包括jquery.event.move.

我希望这对某人有所帮助:)


要回答以下评论:

请记住以正确的顺序包含所有文件,并记住所有文件:

<script type="text/javascript" src="/scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.event.move.js"></script>
<script type="text/javascript" src="/scripts/jquery.event.swipe.js"></script>
<script type="text/javascript" src="/scripts/unslider.min.js"></script>

I already solved this, and I'm only posting to help others save some time.

I am using unslider for a business website, a website I'm making responsive, so the feature of adding touch support to the slider is appealing. Unfortunately it doesn't work straight out of the box, as the author claims.

解决方案

UPDATE
The unslider plugin I used, was outdated. I downloaded it from unslider.com where I first found it( it's still an outdated version there), hence I had the difficulties.

If you need to get the latest version, go to: https://github.com/idiot/unslider/

And if you want to see my issue report: https://github.com/idiot/unslider/issues/69


The problem is that the author hasn't updated his project in 4 months, and since then the swipe event has been moved from $.event.swipe to $.event.special.swipe.

The problem occurs in line 108 of the unslider plugin, where it test for the existence of the swipe plugin.

108: if($.event.swipe) {
109:    this.el.on('swipeleft', _.prev).on('swiperight', _.next);

Just change it to:

108: if($.event.special.swipe) {
109:    this.el.on('swipeleft', _.prev).on('swiperight', _.next);

It's an easy fix, but will take some googling to figure out.

If you want to be sure it will work with earlier versions, you can do this:

108: if($.event.special.swipe || $.event.special.swipe) {
109:    this.el.on('swipeleft', _.prev).on('swiperight', _.next);

But I don't recommend that.

Also, the author doesn't mention this, but the swipe plugin page does, you need to include jquery.event.move in addition to jquery.event.swipe in your scripts.

I hope this helped someone :)


To answer the comment below:

Remember to include all files, in the right order, and remember all of them:

<script type="text/javascript" src="/scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.event.move.js"></script>
<script type="text/javascript" src="/scripts/jquery.event.swipe.js"></script>
<script type="text/javascript" src="/scripts/unslider.min.js"></script>

这篇关于jQuery Unslide-触摸不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆