如何将 iScroll4 与 SwipeView 结合使用?
我正在使用 iScroll4 在移动网站内的图像上创建水平滚动效果。 iScroll 工作得非常好,但问题是 iScroll 包装器中包含的图像禁用了本机垂直滚动。换句话说,用户通过手指滑动来导航页面的操作在 iScroll 包裹图像内的任何位置都被禁用。
SwipeView 也许能够解决这个问题,但是文档(至少对我来说)不是那么清楚。有谁知道如何在 iScroll 包裹的图像上有效使用 SwipeView?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很抱歉几乎重现了已经做出的答案 - 但我需要将一些代码粘贴到不同的空间中。
阿拉斯泰尔的例子对我来说不太适用。我下载的iScroll版本似乎不支持匹配类,它需要一个对象。因此,由于我的项目已经有 jQuery,所以我使用它来传递活动元素。
我将其添加到 demo/inline/test.html 中示例中的
carousel.onFlip()
函数的末尾下载 http://cubiq.org/swipeview尚未进行扩展测试 - 这只是我的东西我在看一点虽然比较了要使用的库的组合,但它使用上面的代码在 Chrome 中按照您的预期工作。
编辑刚刚在iPhone上的移动Safari中进行了测试,链接也位于此处https ://dl.dropbox.com/u/81328343/scroll/test.html
唯一的事情(不确定是好是坏,取决于用例)是返回幻灯片时它跳回顶部。
sorry to pretty much reproduce the answer that's already been made - but I need to paste some code into a different space.
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.
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/swipeviewHaven'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.
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 页面时初始化 iScroll。水平 iScroll 滚动被禁用,这使得该事件可用于 SwipeView,并且方向被锁定,因此在进行垂直(iScroll)滑动时,用户滑动方向的更改不会滑动到下一个 SwipeView 页面。如果没有这些选项,人们可能会进行奇怪的水平滑动。
I've found the documentation to be terribly lacking as well but something like this works for me:
This initialises iScroll on your current SwipeView page upon swiping to it. Horizontal iScroll-scrolling is disabled which leaves that event available to SwipeView and the direction is locked so while a vertical (iScroll) swipe is in progress, a change in the user's swipe-direction won't swipe to the next SwipeView page. Without those options, one can do a bizarre horizontal swipe.