身体滚动鼠标位置?

Sha*_*non 1 jquery scroll

基本上,功能是在这里,它只是需要一些改动,我不知道如何来调整,我已经写了,它正是我想要的这个小片段,但不滚动整个页面,它只是滚动"窗口"大小.

谁能接受这个并让它变得惊人?:)

$(document).mousemove(function(e){
        percent = ((e.pageY) * 100) / $(this).height(); 
        $('body,html').scrollTop( percent);         
});
Run Code Online (Sandbox Code Playgroud)

Ble*_*der 7

有类似的东西吗?http://jsfiddle.net/zcVL7/4/

我把JS简化了一点,但你有大部分内容:

$(document).mousemove(function(e) {
    var percent = e.clientY / $(window).height();
    $('body, html').scrollTop($(document).height() * percent);
});?
Run Code Online (Sandbox Code Playgroud)


pim*_*vdb 5

您可能更愿意根据鼠标相对于页面中间偏移的距离来确定增量:http://jsfiddle.net/BYUdS/2/.这样,您可以继续向下滚动,以便没有滚动限制(您现在拥有的).

$(document).mousemove(function(e) {
    $("html, body").scrollTop(function(i, v) {
        var h = $(window).height();
        var y = e.clientY - h / 2;
        return v + y * 0.1;
    });
});
Run Code Online (Sandbox Code Playgroud)

这是一个更顺畅的版本:http://jsfiddle.net/BYUdS/3/.

var $elems = $("html, body");
var delta = 0;

$(document).on("mousemove", function(e) {
    var h = $(window).height();
    var y = e.clientY - h / 2;
    delta = y * 0.1;
});

$(window).on("blur mouseleave", function() {
    delta = 0;
});

(function f() {
    if(delta) {
        $elems.scrollTop(function(i, v) {
            return v + delta;
        });
    }
    webkitRequestAnimationFrame(f);
})();
Run Code Online (Sandbox Code Playgroud)