mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
some more tweaking and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f61297a84f
commit
e5556fb34b
@ -516,7 +516,7 @@ var BaseBrowserPrototype = {
|
|||||||
// doNested(true, ..)
|
// doNested(true, ..)
|
||||||
// -> items
|
// -> items
|
||||||
//
|
//
|
||||||
// NOTE: doNested(..) has no effect of options.reverseIteration is
|
// NOTE: doNested(..) has no effect of options.reverse is
|
||||||
// set to 'flat'...
|
// set to 'flat'...
|
||||||
// NOTE: only the first call to doNested(..) as any effect, all
|
// NOTE: only the first call to doNested(..) as any effect, all
|
||||||
// consecutive calls will return cached results of the first
|
// consecutive calls will return cached results of the first
|
||||||
@ -564,7 +564,11 @@ var BaseBrowserPrototype = {
|
|||||||
// // NOTE: in 'flat' mode the client loses control over the
|
// // NOTE: in 'flat' mode the client loses control over the
|
||||||
// // order of processing via doNested(..) as it will be
|
// // order of processing via doNested(..) as it will be
|
||||||
// // called before handleItem(..)
|
// // called before handleItem(..)
|
||||||
// reverseIteration: <bool> | 'flat' | 'tree',
|
// reverse: <bool> | 'flat' | 'tree',
|
||||||
|
//
|
||||||
|
// // The value to be used if .reverse is set to true...
|
||||||
|
// defaultReverse: 'tree' (default) | 'flat',
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// // If true include inlined parent id in path...
|
// // If true include inlined parent id in path...
|
||||||
// // XXX not implemented yet -- can we implement this???...
|
// // XXX not implemented yet -- can we implement this???...
|
||||||
@ -573,6 +577,7 @@ var BaseBrowserPrototype = {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
// XXX can we add support for partial walks, i.e. start/end ranges???
|
||||||
// XXX revise protocol...
|
// XXX revise protocol...
|
||||||
walk: function(func, options){
|
walk: function(func, options){
|
||||||
var that = this
|
var that = this
|
||||||
@ -604,7 +609,10 @@ var BaseBrowserPrototype = {
|
|||||||
var iterateNonIterable = options.iterateAll || options.iterateNonIterable
|
var iterateNonIterable = options.iterateAll || options.iterateNonIterable
|
||||||
var iterateCollapsed = options.iterateAll || options.iterateCollapsed
|
var iterateCollapsed = options.iterateAll || options.iterateCollapsed
|
||||||
var skipNested = !options.iterateAll && options.skipNested
|
var skipNested = !options.iterateAll && options.skipNested
|
||||||
var reverse = options.reverseIteration
|
var reverse = options.reverse
|
||||||
|
reverse = reverse === true ?
|
||||||
|
(options.defaultReverse || 'tree')
|
||||||
|
: reverse
|
||||||
|
|
||||||
var isWalkable = userIsWalkable ?
|
var isWalkable = userIsWalkable ?
|
||||||
function(elem){
|
function(elem){
|
||||||
@ -707,7 +715,7 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
// prepend nested elements on flat reverse...
|
// prepend nested elements on flat reverse...
|
||||||
(sublist && options.reverseIteration == 'flat' ?
|
(sublist && reverse == 'flat' ?
|
||||||
doNested(sublist)
|
doNested(sublist)
|
||||||
: [])
|
: [])
|
||||||
// append the actual element...
|
// append the actual element...
|
||||||
@ -798,21 +806,10 @@ var BaseBrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// options format:
|
// options format:
|
||||||
// {
|
// {
|
||||||
// // Reverse iteration order...
|
// // The value used if .reverse is set to true...
|
||||||
// //
|
// //
|
||||||
// // modes:
|
// // NOTE: the default is different from .walk(..)
|
||||||
// // false | null - normal order (default)
|
// defaultReverse: 'flat' (default) | 'tree',
|
||||||
// // true | 'flat' - full flat reverse
|
|
||||||
// // 'tree' - reverse order of levels but keep
|
|
||||||
// // topology order, i.e. containers
|
|
||||||
// // will precede contained elements.
|
|
||||||
// //
|
|
||||||
// // NOTE: in 'flat' mode the client loses control over the
|
|
||||||
// // order of processing via doNested(..) as it will be
|
|
||||||
// // called before handleItem(..)
|
|
||||||
// // NOTE: the semantics of this are slightly different to how
|
|
||||||
// // this option is handled by .walk(..)
|
|
||||||
// reverseIteration: <bool> | 'flat' | 'tree',
|
|
||||||
//
|
//
|
||||||
// // For other supported options see docs for .walk(..)
|
// // For other supported options see docs for .walk(..)
|
||||||
// ...
|
// ...
|
||||||
@ -843,7 +840,6 @@ var BaseBrowserPrototype = {
|
|||||||
// .map(func, path[, options])
|
// .map(func, path[, options])
|
||||||
// .map(func, i, path[, options])
|
// .map(func, i, path[, options])
|
||||||
// these set the "base" path and index passed to func...
|
// these set the "base" path and index passed to func...
|
||||||
// XXX can we avoid argument parsing here???
|
|
||||||
var args = [...arguments]
|
var args = [...arguments]
|
||||||
func = args[0] instanceof Function ?
|
func = args[0] instanceof Function ?
|
||||||
args.shift()
|
args.shift()
|
||||||
@ -856,12 +852,10 @@ var BaseBrowserPrototype = {
|
|||||||
args.shift()
|
args.shift()
|
||||||
: []
|
: []
|
||||||
var options = args.pop() || {}
|
var options = args.pop() || {}
|
||||||
|
options = !options.defaultReverse ?
|
||||||
// normalize .reverseIteration default...
|
|
||||||
options = options.reverseIteration === true ?
|
|
||||||
Object.assign({},
|
Object.assign({},
|
||||||
options,
|
options,
|
||||||
{ reverseIteration: 'flat' })
|
{ defaultReverse: 'flat' })
|
||||||
: options
|
: options
|
||||||
|
|
||||||
return this.walk(
|
return this.walk(
|
||||||
@ -951,7 +945,6 @@ var BaseBrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// XXX this is not too fast for indexing very long lists...
|
// XXX this is not too fast for indexing very long lists...
|
||||||
// XXX use cache for these -- currently these use .map(..)...
|
// XXX use cache for these -- currently these use .map(..)...
|
||||||
// XXX do we need to support negative indexes???
|
|
||||||
get: function(key, options){
|
get: function(key, options){
|
||||||
key = key == null ? 0 : key
|
key = key == null ? 0 : key
|
||||||
key = typeof(key) == typeof('str') ?
|
key = typeof(key) == typeof('str') ?
|
||||||
@ -1017,7 +1010,7 @@ var BaseBrowserPrototype = {
|
|||||||
var i = 0
|
var i = 0
|
||||||
// reverse indexing...
|
// reverse indexing...
|
||||||
options = Object.assign(
|
options = Object.assign(
|
||||||
{reverseIteration: key < 0 && 'flat'},
|
{ reverse: key < 0 },
|
||||||
options || {})
|
options || {})
|
||||||
key = key < 0 ?
|
key = key < 0 ?
|
||||||
-key - 1
|
-key - 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user