mirror of
https://github.com/flynx/PortableMag.git
synced 2025-10-30 03:30:09 +00:00
more cleanup and refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
54f3532edb
commit
1029a087a0
@ -69,7 +69,7 @@
|
|||||||
<script src="lib/scroller.js"></script>
|
<script src="lib/scroller.js"></script>
|
||||||
<script src="lib/keyboard.js"></script>
|
<script src="lib/keyboard.js"></script>
|
||||||
|
|
||||||
<script src="lib/log.js"></script>
|
<!--script src="lib/log.js"></script-->
|
||||||
|
|
||||||
<script src="magazine.js"></script>
|
<script src="magazine.js"></script>
|
||||||
<script src="layout.js"></script>
|
<script src="layout.js"></script>
|
||||||
|
|||||||
@ -34,19 +34,25 @@ var MULTITOUCH_RELEASE_THRESHOLD = 100
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
// Scroll handler
|
||||||
|
//
|
||||||
|
// This will take two elements a root (container) and a scrolled (first
|
||||||
|
// child of the container) and implement drag-scrolling of the scrolled
|
||||||
|
// within the root.
|
||||||
|
//
|
||||||
|
// This calls the following callbacks if they are defined.
|
||||||
|
// - preCallback (unset)
|
||||||
|
// - scrollCallback (unset)
|
||||||
|
// - postCallback (set to postScrollCallback)
|
||||||
|
//
|
||||||
|
// See scroller.options for configuration.
|
||||||
|
//
|
||||||
|
//
|
||||||
// XXX add a resonable cancel scheme...
|
// XXX add a resonable cancel scheme...
|
||||||
// ... something similar to touch threshold but bigger...
|
// ... something similar to touch threshold but bigger...
|
||||||
// XXX handle multiple touches...
|
|
||||||
// - timeout on lift to count fingers...
|
|
||||||
// XXX setup basic styles for the contained element...
|
// XXX setup basic styles for the contained element...
|
||||||
// XXX revise...
|
// XXX revise...
|
||||||
// XXX test on other devices...
|
// XXX test on other devices...
|
||||||
// XXX BUG: on landing a second finger while scrolling the things goes
|
|
||||||
// haywhire...
|
|
||||||
// ...check if this is gone...
|
|
||||||
// XXX add something like a scrollTo that would understand elements as
|
|
||||||
// well as explicit positions.
|
|
||||||
// XXX split this into a seporate lib...
|
|
||||||
function makeScrollHandler(root, config){
|
function makeScrollHandler(root, config){
|
||||||
root = $(root)
|
root = $(root)
|
||||||
|
|
||||||
@ -112,7 +118,6 @@ function makeScrollHandler(root, config){
|
|||||||
// XXX these two are redundant...
|
// XXX these two are redundant...
|
||||||
scrolling = true
|
scrolling = true
|
||||||
scroller.state = 'scrolling'
|
scroller.state = 'scrolling'
|
||||||
options.enabelStartEvent && root.trigger('userScrollStart')
|
|
||||||
// XXX do we need to pass something to this?
|
// XXX do we need to pass something to this?
|
||||||
options.preCallback && options.preCallback()
|
options.preCallback && options.preCallback()
|
||||||
|
|
||||||
@ -178,7 +183,6 @@ function makeScrollHandler(root, config){
|
|||||||
prev_y = y
|
prev_y = y
|
||||||
prev_t = t
|
prev_t = t
|
||||||
|
|
||||||
options.enableUserScrollEvent && root.trigger('userScroll')
|
|
||||||
// XXX do we need to pass something to this?
|
// XXX do we need to pass something to this?
|
||||||
options.scrollCallback && options.scrollCallback()
|
options.scrollCallback && options.scrollCallback()
|
||||||
}
|
}
|
||||||
@ -229,7 +233,6 @@ function makeScrollHandler(root, config){
|
|||||||
// XXX stop only if no fingers are touching or let the callback decide...
|
// XXX stop only if no fingers are touching or let the callback decide...
|
||||||
//togglePageDragging('off')
|
//togglePageDragging('off')
|
||||||
// XXX update this with the new data model!!! (see below)
|
// XXX update this with the new data model!!! (see below)
|
||||||
options.enableEndEvent && root.trigger('userScrollEnd', data)
|
|
||||||
if(options.postCallback
|
if(options.postCallback
|
||||||
// XXX revise this....
|
// XXX revise this....
|
||||||
&& options.postCallback(data) === false
|
&& options.postCallback(data) === false
|
||||||
@ -285,13 +288,6 @@ function makeScrollHandler(root, config){
|
|||||||
eventBounds: 5,
|
eventBounds: 5,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// these control weather in-scroll events will get triggered.
|
|
||||||
// NOTE: these may impact performance, especially the scroll
|
|
||||||
// event, thus they need to enabled explicitly.
|
|
||||||
enabelStartEvent: false,
|
|
||||||
enableUserScrollEvent: false,
|
|
||||||
enableEndEvent: false,
|
|
||||||
|
|
||||||
// callback to be called when the user first touches the screen...
|
// callback to be called when the user first touches the screen...
|
||||||
preCallback: null,
|
preCallback: null,
|
||||||
// callback to be called when a scroll step is done...
|
// callback to be called when a scroll step is done...
|
||||||
@ -384,8 +380,11 @@ function makeScrollHandler(root, config){
|
|||||||
return scroller
|
return scroller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// default callback...
|
// default callback...
|
||||||
// This will provide support for the folowing events on the scroll root
|
//
|
||||||
|
// This will provide support for the following events on the scroll root
|
||||||
// element:
|
// element:
|
||||||
// - scrollCancelled
|
// - scrollCancelled
|
||||||
//
|
//
|
||||||
@ -405,9 +404,9 @@ function makeScrollHandler(root, config){
|
|||||||
// NOTE: data.touches passed to the event is the number of touches
|
// NOTE: data.touches passed to the event is the number of touches
|
||||||
// released within the multitouchTimeout.
|
// released within the multitouchTimeout.
|
||||||
// this differs from what postScrollCallback actually gets in the
|
// this differs from what postScrollCallback actually gets in the
|
||||||
// same field when it recieves the object.
|
// same field when it receives the scroll data object.
|
||||||
// XXX add generic snap
|
// XXX add generic snap
|
||||||
// XXX add generic innertial scroll
|
// XXX add generic inertial scroll
|
||||||
// ...see jli.js/animateElementTo for a rough implementation
|
// ...see jli.js/animateElementTo for a rough implementation
|
||||||
// XXX test multiple touches...
|
// XXX test multiple touches...
|
||||||
function postScrollCallback(data){
|
function postScrollCallback(data){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user