plugin.js 584 字节
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
var gitbook = window.gitbook;

gitbook.events.on('page.change', function() {
	
	var back_to_top_button = ['<div class="back-to-top"><i class="fa fa-arrow-up"></i></div>'].join("");
	$(".book").append(back_to_top_button)

	$(".back-to-top").hide();

	$('.book-body,.body-inner').on('scroll', function () {
		if ($(this).scrollTop() > 100) { 
			$('.back-to-top').fadeIn();
		} else {
			$('.back-to-top').fadeOut();
		}
	});

	$('.back-to-top').click(function () { 
		$('.book-body,.body-inner').animate({
			scrollTop: 0
		}, 800);
		return false;
	});
	
});