全页滚动到下一部分

时间:2017-04-19 22:14:22

标签: javascript jquery scrollto

我尝试将我的整页滚动到下一部分,如果是mouseenter

HTML:

$("#fullpage-left").mouseenter(function() {
        if ($('#fullpage-left .current').next('#fullpage-left .section').length > 0) {
            var $next = $('#fullpage-left .current').next('#fullpage-left .section');
            var top = $next.offset().top;

            $('#fullpage-left .current').removeClass('current');

            $('#fullpage-left').animate({
              scrollTop: top     
            }, function () {
                   $next.addClass('current');
            });
        }
    });

JS:

stacks = {1 => [5,4,3],
          2 => [5,2,1],
          3 => [5]}  # a Hash

 puts "Please select a tower" 
 tower_select = gets.chomp.to_i
 puts "Please select where you'd like to move" 
 tower_move = gets.chomp.to_i

 if stacks[tower_select][-1] < stacks[tower_move][-1]   
   stacks[tower_move] << stacks[tower_select][-1]   
   stacks[tower_select].delete_at(-1)
   #or just: stacks[tower_move] << stacks[tower_select].pop 
 else puts "ERROR: Invalid move"
 end

p stacks

它的工作只适用于2节,接下来只有类当前和没有scrollto。 谁能帮我这个。提前谢谢。

0 个答案:

没有答案
相关问题