mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
fixed a couple of bug in .alignToRibbon(..), now seems to be working fine... still needs more testing.
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b47eecec3c
commit
4842da32fd
@ -587,7 +587,10 @@ actions.Actions({
|
||||
|
||||
|
||||
// complex operations...
|
||||
// XXX align to ribbon...
|
||||
// XXX need interactive mode for this...
|
||||
// - on init: select start/end/base
|
||||
// - allow user to reset/move
|
||||
// - on accept: run
|
||||
alignToRibbon: ['Ribbons|Edit/Align top ribbon to base',
|
||||
function(target, start, end){
|
||||
this.data = this.data.alignToRibbon(target, start, end)
|
||||
|
||||
@ -2216,28 +2216,53 @@ var DataPrototype = {
|
||||
var above = this.getRibbon(r-1)
|
||||
}
|
||||
|
||||
var that = this
|
||||
// get the edge (left/right-most image) of the set of ribbons
|
||||
// above the above ribbon calculated above... (no pun intended)
|
||||
var _getEdge = function(side){
|
||||
return Math[side == 'left' ? 'min' : 'max'].apply(null,
|
||||
that.ribbon_order
|
||||
.map(function(ribbon, i){
|
||||
return i > r-1
|
||||
? null
|
||||
: that.getImageOrder(
|
||||
side == 'left' ? 'first' : 'last',
|
||||
ribbon) })
|
||||
// cleanup...
|
||||
.filter(function(i){
|
||||
return i != null }))
|
||||
}
|
||||
|
||||
start = start == null
|
||||
? this.getImageOrder('first', above)
|
||||
//? this.getImageOrder('first', above)
|
||||
? _getEdge('left')
|
||||
: this.getImageOrder(start)
|
||||
end = end == null
|
||||
// NOTE: we need to exclude the last image in ribbon from
|
||||
// the next section, this the offset.
|
||||
? this.getImageOrder('last', above)+1
|
||||
//? this.getImageOrder('last', above)+1
|
||||
? _getEdge('right')+1
|
||||
: this.getImageOrder(end)
|
||||
|
||||
// split the data into three sections...
|
||||
var res = this.split(start, end)
|
||||
var rest = res.slice(1)
|
||||
|
||||
// cleanup...
|
||||
// XXX do we actually need this???
|
||||
res.forEach(function(e){ e.clear('empty') })
|
||||
res.forEach(function(e){ return e.clear('empty') })
|
||||
|
||||
// set the base ribbon on the middle section...
|
||||
rest[0].setBase(0)
|
||||
res[1].setBase(0)
|
||||
|
||||
// remove empty sections...
|
||||
res = res.filter(function(e){ return e.length > 0 })
|
||||
|
||||
// join the resulting data to the base ribbon...
|
||||
res = res[0].join(rest)
|
||||
// NOTE: if we have only one non-empty section then nothing needs
|
||||
// to be done...
|
||||
if(res.length > 1){
|
||||
res = res[0].join(res.slice(1))
|
||||
}
|
||||
|
||||
// transfer data to new data object...
|
||||
res.current = this.current
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user