在现有垂直 iScroll 内设置轮播 iScroll

发布于 2025-01-02 23:48:34 字数 2073 浏览 3 评论 0原文

我在垂直方向上实施轮播时遇到问题 滚动。由于 Carousel 是水平滚动的,而 iScroll 是 垂直滚动,它会导致旋转木马滚动时出现故障 垂直,即使我禁用它。

我尝试分离两个包装纸(即......),但问题仍然存在。 有人可以告诉我如何解决这个问题。

(我是 Javascript 新手,所以某种示例会很棒)

这是我的脚本:

var myScroll, myWipe; 
function loaded() { 
                myScroll = new iScroll('wrapper1'); 
                myWipe = new iScroll('wrapper2', { 
                snap: true, 
                momentum: false, 
                vscroll: false, 
                hscroll: true, 
                lockDirection: true, 
                hScrollbar: false, 
                onScrollEnd: function () { 
                        document.querySelector('#indicator > li.carouselSelect').className 
= ''; 
                        document.querySelector('#indicator > li:nth-child(' + 
(this.currPageX+1) + ')').className = 'carouselSelect'; 
                } 
         }); 
        }; 

window.addEventListener('load', loaded, false); 

和我的 HTML:

<div id="wrapper1"> 
<div id="scroller1"> 
        <ul class="table-view table-action "> 
                <li></li> 
                <li></li> 

<!--myWipe--> 
<div id="wrapper2"> 
        <div id="scroller2"> 
                <ul> 
                    <li></li> 
                    <li></li> 
                    <li></li> 
                </ul> 
        </div> 
</div> 

<div id="nav"> 
        <div id="prev" onclick="myWipe.scrollToPage('prev', 0);return 
false">&larr; prev</div> 
        <ul id="indicator"> 
                <li class="carouselSelect">1</li> 
                <li>2</li> 
                <li>3</li> 
        </ul> 
        <div id="next" onclick="myWipe.scrollToPage('next', 0);return 
false">next &rarr;</div> 
</div><!--end myWipe--> 
</ul> 
</div><!--end #scroller1--> 
</div><!--end #wrapper1-->

I am having trouble with implementing Carousel inside a vertical
iScroll. Since the Carousel is horizontal scrolling and iScroll is
vertical scrolling, its causing a glitch, in that Carousel scrolls
vertical even if I disabled it.

I tried separating the two wrappers (ie....,...), but the problem is still there.
Can someone tell me how to solve this.

(I am new to Javascript, so some kind of example would be great)

Here's my script:

var myScroll, myWipe; 
function loaded() { 
                myScroll = new iScroll('wrapper1'); 
                myWipe = new iScroll('wrapper2', { 
                snap: true, 
                momentum: false, 
                vscroll: false, 
                hscroll: true, 
                lockDirection: true, 
                hScrollbar: false, 
                onScrollEnd: function () { 
                        document.querySelector('#indicator > li.carouselSelect').className 
= ''; 
                        document.querySelector('#indicator > li:nth-child(' + 
(this.currPageX+1) + ')').className = 'carouselSelect'; 
                } 
         }); 
        }; 

window.addEventListener('load', loaded, false); 

and my HTML:

<div id="wrapper1"> 
<div id="scroller1"> 
        <ul class="table-view table-action "> 
                <li></li> 
                <li></li> 

<!--myWipe--> 
<div id="wrapper2"> 
        <div id="scroller2"> 
                <ul> 
                    <li></li> 
                    <li></li> 
                    <li></li> 
                </ul> 
        </div> 
</div> 

<div id="nav"> 
        <div id="prev" onclick="myWipe.scrollToPage('prev', 0);return 
false">← prev</div> 
        <ul id="indicator"> 
                <li class="carouselSelect">1</li> 
                <li>2</li> 
                <li>3</li> 
        </ul> 
        <div id="next" onclick="myWipe.scrollToPage('next', 0);return 
false">next →</div> 
</div><!--end myWipe--> 
</ul> 
</div><!--end #scroller1--> 
</div><!--end #wrapper1-->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

篱下浅笙歌 2025-01-09 23:48:34

给你...

http://jsfiddle.net/manseuk/r9VL2/2/

垂直滚动内的水平旋转木马。

Here you go...

http://jsfiddle.net/manseuk/r9VL2/2/

A horizontal carousel inside a vertical scroll.

烟织青萝梦 2025-01-09 23:48:34

尝试将 myWipe 移至无序列表之外。

Try moving your myWipe to the outside of the unordered list.

洒一地阳光 2025-01-09 23:48:34

如果您需要多方向滚动,可以尝试 Motus.js

*免责声明:我编写了该库。

If you're after multi-directional scrolling you can try Motus.js out.

*Disclaimer: I wrote the library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文