mirror of
https://github.com/flynx/PortableMag.git
synced 2025-12-20 18:41:46 +00:00
another attempt to tame the scroll...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c3486c9c71
commit
d4eebe7c05
47
layout.html
47
layout.html
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
<script src="ext-lib/jquery.js"></script>
|
<script src="ext-lib/jquery.js"></script>
|
||||||
<script src="ext-lib/jquery.scrollto.js"></script>
|
<script src="ext-lib/jquery.scrollto.js"></script>
|
||||||
<script src="ext-lib/jquery.scrollstop.js"></script>
|
<!--script src="ext-lib/jquery.scrollstop.js"></script-->
|
||||||
|
|
||||||
<script src="lib/jli.js"></script>
|
<script src="lib/jli.js"></script>
|
||||||
|
|
||||||
@ -66,7 +66,6 @@
|
|||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// log...
|
// log...
|
||||||
/*
|
|
||||||
var _log = $('<div id="log"></div>')
|
var _log = $('<div id="log"></div>')
|
||||||
.css({
|
.css({
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
@ -89,7 +88,6 @@ $(document).ready(function(){
|
|||||||
function clear_log(){
|
function clear_log(){
|
||||||
_log.html('')
|
_log.html('')
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// keyboard...
|
// keyboard...
|
||||||
$(document)
|
$(document)
|
||||||
@ -116,7 +114,46 @@ $(document).ready(function(){
|
|||||||
function(k){console.log(k)}))
|
function(k){console.log(k)}))
|
||||||
|
|
||||||
|
|
||||||
if(NAVIGATE_RELATIVE_TO_VISIBLE){
|
window.scroll_state = 'none'
|
||||||
|
window.SCROLL_STOP_THRESHOLD = 0
|
||||||
|
window.SCROLL_CHECK_INTERVAL = 50
|
||||||
|
|
||||||
|
window._scroll_offset = null
|
||||||
|
var v = $('.viewer')
|
||||||
|
|
||||||
|
setInterval(function(){
|
||||||
|
var c = v.scrollLeft()
|
||||||
|
if(scroll_state == 'kinetic'
|
||||||
|
&& (_scroll_offset - c) < SCROLL_STOP_THRESHOLD){
|
||||||
|
scroll_state = 'none'
|
||||||
|
v.trigger('scrollstop')
|
||||||
|
}
|
||||||
|
}, SCROLL_CHECK_INTERVAL)
|
||||||
|
|
||||||
|
window._cur_page = 0
|
||||||
|
|
||||||
|
$('.viewer')
|
||||||
|
.on('scroll', function(){
|
||||||
|
var c = getPageNumber()
|
||||||
|
if(_cur_page != c && scroll_state == 'touching'){
|
||||||
|
log('page: '+c)
|
||||||
|
//setCurrentPage(c)
|
||||||
|
$('.current.page').removeClass('current')
|
||||||
|
$($('.page')[c]).addClass('current')
|
||||||
|
_cur_page = c
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('mousedown touchstart', function(){
|
||||||
|
log('touching...')
|
||||||
|
scroll_state = 'touching'
|
||||||
|
})
|
||||||
|
.on('mouseup touchend', function(){
|
||||||
|
log('kinetic...')
|
||||||
|
scroll_state = 'kinetic'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
//if(NAVIGATE_RELATIVE_TO_VISIBLE){
|
||||||
$('.viewer')
|
$('.viewer')
|
||||||
.on('scrollstop', function(evt){
|
.on('scrollstop', function(evt){
|
||||||
log('scrollstop...')
|
log('scrollstop...')
|
||||||
@ -125,7 +162,7 @@ $(document).ready(function(){
|
|||||||
// .ScrollTo does notwork...
|
// .ScrollTo does notwork...
|
||||||
setCurrentPage()
|
setCurrentPage()
|
||||||
})
|
})
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(!NAVIGATE_RELATIVE_TO_VISIBLE){
|
if(!NAVIGATE_RELATIVE_TO_VISIBLE){
|
||||||
$('.viewer').css({overflow: 'hidden'})
|
$('.viewer').css({overflow: 'hidden'})
|
||||||
|
|||||||
@ -4,8 +4,8 @@
|
|||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
var NAVIGATE_RELATIVE_TO_VISIBLE = false
|
//var NAVIGATE_RELATIVE_TO_VISIBLE = false
|
||||||
//var NAVIGATE_RELATIVE_TO_VISIBLE = true
|
var NAVIGATE_RELATIVE_TO_VISIBLE = true
|
||||||
|
|
||||||
var USE_PAGE_ALIGN = true
|
var USE_PAGE_ALIGN = true
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user