mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
add page flip
This commit is contained in:
parent
98b4bfa8a4
commit
9ba539d7b5
16
js/ditto.js
16
js/ditto.js
@ -17,6 +17,10 @@ var ditto = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var disqusCode = '<h3>留言</h3><div id="disqus_thread"></div>';
|
var disqusCode = '<h3>留言</h3><div id="disqus_thread"></div>';
|
||||||
|
var header = $('#flip'),
|
||||||
|
headerHeight = 30,
|
||||||
|
treshold = 0,
|
||||||
|
lastScroll = 0;
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
// initialize sidebar and buttons
|
// initialize sidebar and buttons
|
||||||
@ -35,7 +39,17 @@ function initialize() {
|
|||||||
// page router
|
// page router
|
||||||
router();
|
router();
|
||||||
$(window).on('hashchange', router);
|
$(window).on('hashchange', router);
|
||||||
}
|
$(document).on('scroll', function (evt) {
|
||||||
|
var newScroll = $(document).scrollTop(),
|
||||||
|
diff = newScroll-lastScroll;
|
||||||
|
treshold = (treshold+diff>headerHeight) ? headerHeight : treshold+diff;
|
||||||
|
treshold = (treshold < 0) ? 0 : treshold;
|
||||||
|
|
||||||
|
header.css('bottom', (-treshold)+'px');
|
||||||
|
|
||||||
|
lastScroll = newScroll;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function init_sidebar_section() {
|
function init_sidebar_section() {
|
||||||
$.get(ditto.sidebar_file, function(data) {
|
$.get(ditto.sidebar_file, function(data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user