mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
bugfix + tweaking and experementing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2c43cd5fc4
commit
3f1288cc04
@ -522,6 +522,17 @@ var BrowserViewMixin = {
|
|||||||
set container(value){
|
set container(value){
|
||||||
getMixinRoot(this, '__container').container = value },
|
getMixinRoot(this, '__container').container = value },
|
||||||
|
|
||||||
|
// refresh local items if/when diverging from .source...
|
||||||
|
get items(){
|
||||||
|
return this.hasOwnProperty('__items')
|
||||||
|
&& this.isCurrent() ?
|
||||||
|
this.__items
|
||||||
|
: this.__refresh() },
|
||||||
|
|
||||||
|
// check if we are current with .source...
|
||||||
|
isCurrent: function(){
|
||||||
|
return new Set(Object.values(this.source.index)).has(this.__items[0]) },
|
||||||
|
|
||||||
isView: function(){
|
isView: function(){
|
||||||
return true },
|
return true },
|
||||||
end: function(){
|
end: function(){
|
||||||
@ -533,23 +544,23 @@ var BrowserViewMixin = {
|
|||||||
// XXX should this be .refresh()???
|
// XXX should this be .refresh()???
|
||||||
// ...if yes what's going to be the difference between it here
|
// ...if yes what's going to be the difference between it here
|
||||||
// and in the source object???
|
// and in the source object???
|
||||||
// XXX also need to track source objects .make(..) calls...
|
|
||||||
// ...not sure of the correct way to do this, "weak" event handler???
|
|
||||||
// XXX how do we handle sections???
|
// XXX how do we handle sections???
|
||||||
__refresh: function(){
|
__refresh: function(){
|
||||||
var source = this.source
|
var source = this.source
|
||||||
var [action, ...args] = this.query
|
var [action, ...args] = this.query
|
||||||
|
|
||||||
this.items =
|
this.clearCache()
|
||||||
|
|
||||||
|
return (this.items =
|
||||||
action instanceof Array ?
|
action instanceof Array ?
|
||||||
action
|
action
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
return that.get(e) })
|
return source.get(e) })
|
||||||
: action ?
|
: action ?
|
||||||
source[action](...args)
|
source[action](...args)
|
||||||
: source.items.slice()
|
: source.items.slice())
|
||||||
|
|
||||||
return this
|
//return this
|
||||||
},
|
},
|
||||||
make: function(){
|
make: function(){
|
||||||
var res = this.__proto__.make(...arguments)
|
var res = this.__proto__.make(...arguments)
|
||||||
@ -1634,6 +1645,7 @@ var BaseBrowserPrototype = {
|
|||||||
make.dialog = this
|
make.dialog = this
|
||||||
|
|
||||||
// build the sections...
|
// build the sections...
|
||||||
|
var reset_index = false
|
||||||
sections
|
sections
|
||||||
.forEach(function([name, handler]){
|
.forEach(function([name, handler]){
|
||||||
// setup closure for make(..)...
|
// setup closure for make(..)...
|
||||||
@ -1642,6 +1654,9 @@ var BaseBrowserPrototype = {
|
|||||||
ids = new Set()
|
ids = new Set()
|
||||||
list = make.items = that[name] = []
|
list = make.items = that[name] = []
|
||||||
|
|
||||||
|
// prepare for index reset...
|
||||||
|
reset_index = reset_index || name == 'items'
|
||||||
|
|
||||||
// build list...
|
// build list...
|
||||||
var res = handler.call(that,
|
var res = handler.call(that,
|
||||||
make,
|
make,
|
||||||
@ -1660,7 +1675,7 @@ var BaseBrowserPrototype = {
|
|||||||
// reset the index/cache...
|
// reset the index/cache...
|
||||||
// XXX should this be only for .items???
|
// XXX should this be only for .items???
|
||||||
// ...should this be global (all items?)
|
// ...should this be global (all items?)
|
||||||
if(sections.includes('items')){
|
if(reset_index){
|
||||||
var old_index = this.__item_index_cache || {}
|
var old_index = this.__item_index_cache || {}
|
||||||
this.clearCache()
|
this.clearCache()
|
||||||
|
|
||||||
@ -3606,8 +3621,7 @@ var BaseBrowserPrototype = {
|
|||||||
// XXX
|
// XXX
|
||||||
query: [...arguments],
|
query: [...arguments],
|
||||||
},
|
},
|
||||||
BrowserViewMixin)
|
BrowserViewMixin) },
|
||||||
.__refresh() },
|
|
||||||
isView: function(){
|
isView: function(){
|
||||||
return false },
|
return false },
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user