added pages and keyboard navigation
This commit is contained in:
+71
@@ -0,0 +1,71 @@
|
||||
$(document).ready(function() {
|
||||
console.log("ready");
|
||||
|
||||
var _current_pages = -1,
|
||||
_page_left_bg, _page_right_bg,
|
||||
_$page_left = $('#page-left'), _$page_right = $('#page-right'),
|
||||
_bgs_prefix = "images/pages/";
|
||||
|
||||
// ____ _ __
|
||||
// / _/___ (_) /_
|
||||
// / // __ \/ / __/
|
||||
// _/ // / / / / /_
|
||||
// /___/_/ /_/_/\__/
|
||||
|
||||
function init(){
|
||||
console.log("init", _$page_left);
|
||||
initkeyboard();
|
||||
changePages();
|
||||
};
|
||||
|
||||
// ____
|
||||
// / __ \____ _____ ____ _____
|
||||
// / /_/ / __ `/ __ `/ _ \/ ___/
|
||||
// / ____/ /_/ / /_/ / __(__ )
|
||||
// /_/ \__,_/\__, /\___/____/
|
||||
// /____/
|
||||
|
||||
function nextPages(){
|
||||
if(_current_pages < _PAGES.length-2){
|
||||
_current_pages+=2;
|
||||
changePages();
|
||||
}
|
||||
};
|
||||
|
||||
function prevPages(){
|
||||
if(_current_pages > -1){
|
||||
_current_pages-=2;
|
||||
changePages();
|
||||
}
|
||||
};
|
||||
|
||||
function changePages(){
|
||||
console.log("changePages");
|
||||
_page_left_bg = _bgs_prefix+_PAGES[_current_pages];
|
||||
_page_right_bg = _bgs_prefix+_PAGES[_current_pages+1];
|
||||
console.log(_page_left_bg+" | "+_page_right_bg);
|
||||
|
||||
_$page_left.css({'background-image': "url("+_page_left_bg+")"});
|
||||
_$page_right.css({'background-image': "url("+_page_right_bg+")"});
|
||||
|
||||
};
|
||||
|
||||
// __ __ __ __
|
||||
// / //_/__ __ __/ /_ ____ ____ __________/ /
|
||||
// / ,< / _ \/ / / / __ \/ __ \/ __ `/ ___/ __ /
|
||||
// / /| / __/ /_/ / /_/ / /_/ / /_/ / / / /_/ /
|
||||
// /_/ |_\___/\__, /_.___/\____/\__,_/_/ \__,_/
|
||||
// /____/
|
||||
function initkeyboard(){
|
||||
keyboardJS.bind('right', function(event) {
|
||||
// console.log(event);
|
||||
nextPages();
|
||||
});
|
||||
keyboardJS.bind('left', function(event) {
|
||||
// console.log(event);
|
||||
prevPages();
|
||||
});
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
Reference in New Issue
Block a user