如何在SwipeView中使用iScroll4? [英] How to use iScroll4 with SwipeView?

查看:292
本文介绍了如何在SwipeView中使用iScroll4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iScroll4在移动网站中的图像上创建水平滚动效果. iScroll的工作原理很棒,但是问题是iScroll包装器中包含的图像禁用了本机垂直滚动.换句话说,在iScroll包装的图像中的任何位置,用户的手指轻扫以浏览页面都被禁用.

I'm using iScroll4 to create a horizontal scroll effect on an image within a mobile website. iScroll works fantastic, but the problem is the image contained in the iScroll wrapper disables native vertical scrolling. In other words, a user's finger swipe to navigate the page is disabled anywhere within the iScroll wrapped image.

SwipeView也许可以解决此问题,但是文档(至少对我来说)不清楚.有谁知道如何在iScroll包装的图像上有效使用SwipeView?

SwipeView may be able to solve this problem, but the documentation (atleast for me) is not that clear. Does anyone know how to effectively use SwipeView on an iScroll wrapped image?

推荐答案

很抱歉,它会重现已经做出的答案-但我需要将一些代码粘贴到其他空间中.

sorry to pretty much reproduce the answer that's already been made - but I need to paste some code into a different space.

Alastair的例子对我而言并不奏效.我下载的iScroll版本似乎不支持匹配类,它需要一个对象.因此,由于我的项目已经有了jQuery,所以我使用它来传递活动元素.

Alastair's example didn't quite work for me. The version of iScroll I downloaded didn't seem to support matching a class, it wanted an object. So since my project has jQuery already I used that to pass the active element in.

scroller = new iScroll($('.swipeview-active')[0], {
  hScroll: false,
  lockDirection: true,
  hideScrollbar: true,
  fadeScrollbar: true
});

我将此示例添加到了carousel.onFlip()函数的末尾. > http://cubiq.org/swipeview

I added this to the end of the carousel.onFlip() function from the example at demo/inline/test.html in the download for http://cubiq.org/swipeview

还没有进行扩展测试-这只是我在比较要使用的库组合时正在查看的内容,但是它可以按照您期望的那样在Chrome中使用上面的代码工作.

Haven't done extended testing - this is just something I'm looking at a bit while comparing cominbation of libraries to use but it's working as you'd expect in Chrome using the code above.

编辑刚刚在iPhone上的移动浏览器中进行了测试,也请在此处链接

EDIT Just tested in mobile safari on iphone too link here https://dl.dropbox.com/u/81328343/scroll/test.html

唯一的事情(不确定用的好还是坏,取决于用例)是,当返回幻灯片时,它会跳回到顶部.

Only thing (not sure if it's good or bad, depends on use case) is that when returning to a slide it jumps back to the top.

这篇关于如何在SwipeView中使用iScroll4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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