简体   繁体   English

如何使用Iscroll滚动修订元素?

[英]How to scroll fix elements using Iscroll?

I am using iscroll in my project.I want to scroll 3 item at one time when user scroll id it possible using iscroll library ?I already try to scrollTo but it will not work ? 我在我的项目中使用iscroll。我想一次滚动3个项目,当用户滚动id时可以使用iscroll库吗?我已经尝试过scrollTo但它不起作用?

Here is my fiddle. 这是我的小提琴。 http://jsfiddle.net/amnishyadav/dWYJS/ http://jsfiddle.net/amnishyadav/dWYJS/

var isScrolling = false;
myScroll = new iScroll('headerWrapper',{
    snap: 'li',
    hScrollbar: false,
    vScrollbar: false,
    momentum: true,
    vScroll: false,
    onScrollMove : function(e){
        // clearHeaderInterval();
        // myScroll.scrollTo(50, 0);
        // myScroll.refresh();

        console.log('onScrollMove===============>>>>>>>>>>>>>');
        isScrolling = true;

        // here get the device type and version
        if(deviceType() == 'android'){
            var deviceVersion = device.version;

            console.log(" deviceType is ===>>"+deviceVersion);
            if(deviceVersion=='4.1' || deviceVersion=='4.1.1'|| deviceVersion=='4.1.2'){
                console.log("android version is ===>>"+deviceVersion);
                setTimeout(function(){
                    myScroll.refresh();
                }, 1000);
            }
        }
        // setTimeout(function(){myScroll.refresh();},0);
    },

});

I'm not quite sure what you're asking here, do you want to have 3 different scrollable areas that can each be scrolled separately from each other? 我不太确定您在这里要问的内容,您是否想拥有3个可分别滚动的不同可滚动区域? If so then you can just initiate the scroll event on each area you want to scroll. 如果是这样,那么您可以仅在要滚动的每个区域上启动滚动事件。

<div id="firstScroller">
    <div class="scroller">
    <!-- content here -->
    </div>
</div>

<div id="secondScroller">
    <div class="scroller">
    <!-- content here -->
    </div>
</div>

<div id="thirdScroller">
    <div class="scroller">
    <!-- content here -->
    </div>
</div>


function loaded() {
    setTimeout(function () {
         firstScroller = new iScroll('firstScroller', {
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false
        });
        secondScroller = new iScroll('secondScroller', {
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false
        });
        thirdScroller = new iScroll('thirdScroller', {
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false
        });
    }, 100);
}

document.addEventListener('DOMContentLoaded', loaded, false);

If that's not what you're after then if you could update your question I might be able to help 如果那不是您想要的,那么如果您可以更新问题,我也许可以为您提供帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM