分享一则JavaScript滚动条插件源码

2020-05-23 06:21:34易采站长站整理

                /// <returns type=”void” />
                if (currTop <= currScroll.topLimit || currTop < 0) {//顶部极限
                    currTop = currScroll.topLimit;
                } else if (currTop >= currScroll.bottomLimit) {//底部极限
                    currTop = currScroll.bottomLimit;
                }
                //滚动条偏移效果
                currScroll.scrollUl.style.top = currTop + ‘px’;
                var tempTop = parseInt(currScroll.context.style.top ? currScroll.context.style.top : 0);
                //debug code
                //                document.getElementById(‘postionInfo’).innerHTML = ‘currTop:’ + currTop + ‘ 滚动基数:’ + currScroll.scrollRadix + ‘ bottomLimit:’ + currScroll.bottomLimit + ‘ endTop:’ + currScroll.endTop + ‘ startTop:’ + currScroll.startTop + ” Y:” + currTop + ” offsetTop:” + currScroll.scrollUl.offsetTop + ” compute:” + (currTop * currScroll.scrollRadix * -1) + ‘px’;
                //text code
                //内容滚动:当前滚动条top*基数取负数
                currScroll.context.style.top = currTop * currScroll.scrollRadix * -1 + ‘px’;
            };
            return currScroll;
        };
    };
    linkFlyScroll.prototype.init.prototype.change = function () {
        /// <summary>
        ///     1: 滚动条内容改变函数
        ///         1.1 – change() – 本函数代表刷新本滚动条对象的数据,在某些情况下,内容的数据是一直在变化的,可以调用本函数对当前滚动条对象刷新数据