redone next/prev page browser actions, good enough but not yet happy with them...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-01 03:05:05 +03:00
parent 2f9ea524ff
commit 837c47ab75
2 changed files with 71 additions and 51 deletions

View File

@ -1349,6 +1349,7 @@ var BrowserPrototype = {
var h = elem.height() var h = elem.height()
var t = elem.offset().top - p.offset().top var t = elem.offset().top - p.offset().top
// XXX should this be in config???
var D = 3 * h var D = 3 * h
// too low... // too low...
@ -1423,75 +1424,91 @@ var BrowserPrototype = {
}) })
.last() .last()
}, },
// NOTE: this will not give a number greater than the number of
// elements, thus for lists without scroll, this will allways
// return the number of elements.
// XXX this will not count the elements at the top if they are
// disabled...
getHeightInElems: function(){
var t = this.getTopVisibleElem()
var b = this.getBottomVisibleElem()
// XXX merge with .select(..)... var res = 1
// XXX needs testing... while(!t.is(b)){
t = t.next()
if(t.length == 0){
break
}
res += 1
}
return res
},
// XXX there are two modes of doing page travel:
// 1) keep relative to page position
// 2) travel up on top element and down on bottom (curret)
// ...is this the natural choice?
// XXX merge with .select(..)???
prevPage: function(){ prevPage: function(){
var pattern = '.list>div:not(.disabled):not(.filtered-out):visible' var t = this.getTopVisibleElem()
var elem = this.getTopVisibleElem()
var cur = this.select('!') var cur = this.select('!')
var p = elem.scrollParent()
var S = p.scrollTop()
var H = p.height()
var T = p.offset().top
// jump to top visible elem if it's not the one selected... // nothing selected...
if(cur.length == 0 || (3 * elem.height()) + S < cur.position().top ){ if(cur.length == 0
this.select(elem.prev(pattern).length == 0 ? elem : elem.next()) // element not near the top...
// XXX make the delta configurable (see .select(..)
// for same issue)...
|| cur.offset().top - t.offset().top > (3 * t.height())){
// select top...
this.select(t)
// we are at the top or we are less than a page from the top... // make the top bottom...
} else if(S <= H){
this.select('first')
// get the next page...
// XXX test...
} else { } else {
var t = S - H var p = t.scrollParent()
var S = p.scrollTop()
var H = p.height()
var elems = this.filter('*') // rough scroll...
this.select(elems // XXX make the delta configurable (see .select(..)
.slice(0, elems.index(elem)) // for same issue)...
.reverse() p.scrollTop(S - (H - 4 * t.height()))
.filter(function(i, e){
return $(e).offset().top - T >= t // select the element and fix scrolling errors...
}) this.select(this.getTopVisibleElem())
.first())
} }
return this return this
}, },
// XXX not finished and buggy.... // XXX this is essentially identical to .prevPage(..)
// XXX merge with .select(..)...
// XXX needs testing...
nextPage: function(){ nextPage: function(){
var elem = this.getBottomVisibleElem() var b = this.getBottomVisibleElem()
var cur = this.select('!') var cur = this.select('!')
var p = elem.scrollParent()
var S = p.scrollTop()
var H = p.height()
var T = p.offset().top
// jump to first elem if it's not the one selected... // nothing selected...
if(cur.length == 0 || S + H - (3 * cur.height()) > cur.position().top ){ if(cur.length == 0
this.select(elem.prev()) // element not near the top...
// XXX make the delta configurable (see .select(..)
// for same issue)...
|| b.offset().top - cur.offset().top > (3 * b.height())){
// select bottom...
this.select(b)
// we are at the bottom or we are less than a page from the bottom... // make the top bottom...
} else if(S + H >= p[0].scrollHeight){
this.select('last')
// get the next page...
} else { } else {
var t = S + 2 * H var p = b.scrollParent()
var S = p.scrollTop()
var H = p.height()
var elems = this.filter('*') // rough scroll...
this.select(elems // XXX make the delta configurable (see .select(..)
.slice(elems.index(elem)) // for same issue)...
.filter(function(i, e){ p.scrollTop(S + (H - 4 * b.height()))
return $(e).offset().top - T >= t
}) // select the element and fix scrolling errors...
.first()) this.select(this.getBottomVisibleElem())
} }
return this return this

View File

@ -3306,12 +3306,14 @@ var FileSystemLoaderActions = actions.Actions({
}], }],
// XXX auto-detect format or let the user chose... // XXX auto-detect format or let the user chose...
loadPath: ['File/Load path', loadPath: ['File/Load path (STUB)',
function(){ function(){
}], }],
}) })
// XXX add load history to this...
// ...might be good to add a generic history feature and use that...
// XXX is this a good name??? // XXX is this a good name???
var FileSystemLoader = var FileSystemLoader =
module.FileSystemLoader = ImageGridFeatures.Feature({ module.FileSystemLoader = ImageGridFeatures.Feature({
@ -3355,6 +3357,7 @@ var FileSystemLoaderUIActions = actions.Actions({
'path-loaders': [ 'path-loaders': [
'loadIndex', 'loadIndex',
'loadImages', 'loadImages',
//'loadPath',
], ],
}, },