mirror of
https://github.com/flynx/ImageGrid.git
synced 2026-11-12 22:11:24 +00:00
refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
23d4331881
commit
890ee1e738
@ -728,6 +728,10 @@ stretching in width... */
|
||||
|
||||
/* XXX we are taking care of this in code -- see if we can use this */
|
||||
image-orientation: none;
|
||||
|
||||
/* XXX does this affect gifs???
|
||||
animation-play-state: paused;
|
||||
*/
|
||||
}
|
||||
|
||||
.image {
|
||||
|
||||
@ -35,20 +35,50 @@ var core = require('features/core')
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
// Merge indexi into the first/base...
|
||||
//
|
||||
// merge(base, ...)
|
||||
// -> res
|
||||
//
|
||||
// res format:
|
||||
// {
|
||||
// base: <index>,
|
||||
//
|
||||
// // sparse array (optional)...
|
||||
// conflicts: [
|
||||
// ...
|
||||
// // conflict objects are at positions corresponding to its
|
||||
// // input index in the arguments....
|
||||
// // for format see: Data's .join(..)
|
||||
// <conflict-object>,
|
||||
// ...
|
||||
// ],
|
||||
// }
|
||||
//
|
||||
var merge =
|
||||
module.merge =
|
||||
function(base, ...others){
|
||||
// XXX get deconfliction mode...
|
||||
// XXX
|
||||
var res = { base }
|
||||
var i = 0
|
||||
for(var other of others){
|
||||
i++
|
||||
// merge data...
|
||||
base.data.join(other.data)
|
||||
// deconflict...
|
||||
for(var c in base.data.deconfliction ?? {}){
|
||||
var n = base.data.deconfliction[c]
|
||||
other.images.replaceGID(c, n) }
|
||||
delete base.data.deconfliction
|
||||
// NOTE: .data.join(..) deconflicts data internally, we need to keep
|
||||
// the deconflicted GIDs in sync with .images...
|
||||
if(base.data.deconfliction){
|
||||
res.conflicts ??= []
|
||||
res.conflicts[i] = base.data.deconfliction
|
||||
for(var c in base.data.deconfliction ?? {}){
|
||||
var n = base.data.deconfliction[c]
|
||||
other.images.replaceGID(c, n) }
|
||||
delete base.data.deconfliction }
|
||||
// merge images...
|
||||
base.images.join(other.images) }
|
||||
return base }
|
||||
return res }
|
||||
|
||||
|
||||
|
||||
|
||||
@ -367,7 +367,10 @@ var FileSystemLoaderActions = actions.Actions({
|
||||
//console.log('MERGING:', k, part)
|
||||
logger && logger.emit('merge index', k, res)
|
||||
|
||||
index = that.merge(index, part) }
|
||||
var {base, conflicts} = that.merge(index, part)
|
||||
index = base
|
||||
|
||||
conflicts && logger && logger.emit('GID conflicts', conflicts) }
|
||||
|
||||
loaded.push(k) }
|
||||
|
||||
@ -780,9 +783,12 @@ var FileSystemLoaderActions = actions.Actions({
|
||||
var new_data = that.data.constructor.fromArray(gids)
|
||||
|
||||
// prepend to index...
|
||||
// NOTE: we are ignoring conflicts here as we are
|
||||
// generating the index ouselves...
|
||||
var index = that.merge(
|
||||
{ data: new_data, images: imgs },
|
||||
that)
|
||||
{ data: new_data, images: imgs },
|
||||
that)
|
||||
.base
|
||||
var cur = that.data.current
|
||||
that.images = index.images
|
||||
that.data = index.data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user