mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-31 19:30:07 +00:00
added relative ribbon alignment, needs more testing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b2a8cc71fc
commit
7c140244be
@ -60,12 +60,14 @@ function getScreenWidthInImages(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: in strict mode this will return null if no image is before the
|
||||||
|
// target...
|
||||||
// NOTE: if this can't find an image if an order less, it will return
|
// NOTE: if this can't find an image if an order less, it will return
|
||||||
// the first image in ribbon...
|
// the first image in ribbon...
|
||||||
// NOTE: this might return an empty target if the ribbon is empty...
|
// NOTE: this might return an empty target if the ribbon is empty...
|
||||||
// XXX need tp make this loadable ribbon compatible -- the target may
|
// XXX need tp make this loadable ribbon compatible -- the target may
|
||||||
// not be loaded...
|
// not be loaded...
|
||||||
function getImageBefore(image, ribbon, mode){
|
function getImageBefore(image, ribbon, mode, strict){
|
||||||
if(mode == null){
|
if(mode == null){
|
||||||
mode = NAV_DEFAULT
|
mode = NAV_DEFAULT
|
||||||
}
|
}
|
||||||
@ -76,7 +78,7 @@ function getImageBefore(image, ribbon, mode){
|
|||||||
var images = $(ribbon).find('.image').filter(mode)
|
var images = $(ribbon).find('.image').filter(mode)
|
||||||
// XXX need to process/format this correctly...
|
// XXX need to process/format this correctly...
|
||||||
var order = JSON.parse(image.attr('order'))
|
var order = JSON.parse(image.attr('order'))
|
||||||
var prev = images.first()
|
var prev = strict ? [] : images.first()
|
||||||
|
|
||||||
images.each(function(){
|
images.each(function(){
|
||||||
if(order < $(this).attr('order')){
|
if(order < $(this).attr('order')){
|
||||||
@ -293,9 +295,9 @@ function centerImage(image, mode){
|
|||||||
|
|
||||||
// zero out top/left if set to anything other than a specific number...
|
// zero out top/left if set to anything other than a specific number...
|
||||||
var t = parseFloat(ribbons.css('top'))
|
var t = parseFloat(ribbons.css('top'))
|
||||||
t = t ? t : 0
|
t = !isNaN(t) ? t : 0
|
||||||
var l = parseFloat(ribbons.css('left'))
|
var l = parseFloat(ribbons.css('left'))
|
||||||
l = l ? l : 0
|
l = !isNaN(l) ? l : 0
|
||||||
|
|
||||||
|
|
||||||
var res = {
|
var res = {
|
||||||
@ -312,6 +314,51 @@ function centerImage(image, mode){
|
|||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX this produces errors in marked-only mode...
|
||||||
|
function centerRibbon(ribbon, mode){
|
||||||
|
if(mode == null){
|
||||||
|
//mode = 'css'
|
||||||
|
mode = 'animate'
|
||||||
|
}
|
||||||
|
ribbon = $(ribbon)
|
||||||
|
var cur = $('.current.image')
|
||||||
|
|
||||||
|
// if centering current ribbon, just center the image...
|
||||||
|
if(ribbon.find('.current.image').length > 0){
|
||||||
|
centerImage(cur, mode)
|
||||||
|
return ribbon
|
||||||
|
}
|
||||||
|
|
||||||
|
var scale = getElementScale($('.ribbon-set'))
|
||||||
|
var target = getImageBefore(null, ribbon, null, true)
|
||||||
|
|
||||||
|
if(target.length > 0){
|
||||||
|
var dl = getRelativeVisualPosition(target, $('.current.image')).left/scale
|
||||||
|
var l = parseFloat(ribbon.css('left'))
|
||||||
|
l = !isNaN(l) ? l : 0
|
||||||
|
l = {left: l + dl - ($('.image').outerWidth()/2)}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var dl = getRelativeVisualPosition(ribbon.find('.image').filter(NAV_DEFAULT).first(), $('.current.image')).left/scale
|
||||||
|
var l = parseFloat(ribbon.css('left'))
|
||||||
|
l = !isNaN(l) ? l : 0
|
||||||
|
l = {left: l + dl + ($('.image').outerWidth()/2)}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode == 'animate'){
|
||||||
|
ribbon.stop().animate(l, 100, 'linear')
|
||||||
|
} else {
|
||||||
|
ribbons.css(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ribbon
|
||||||
|
}
|
||||||
|
|
||||||
|
// a shorthand...
|
||||||
|
function centerRibbons(mode){
|
||||||
|
return $('.ribbon').each(function(){ centerRibbon($(this), mode) })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|||||||
@ -32,10 +32,12 @@ var KEYBOARD_CONFIG = {
|
|||||||
_STEPS_LEFT_TO_CHANGE_DIRECTION = 2
|
_STEPS_LEFT_TO_CHANGE_DIRECTION = 2
|
||||||
}
|
}
|
||||||
prevImage()
|
prevImage()
|
||||||
|
centerRibbons()
|
||||||
},
|
},
|
||||||
// XXX prevScreenImages...
|
// XXX prevScreenImages...
|
||||||
ctrl: function(){
|
ctrl: function(){
|
||||||
prevScreenImages()
|
prevScreenImages()
|
||||||
|
centerRibbons()
|
||||||
},
|
},
|
||||||
// XXX need to keep shift explicitly clear for editor...
|
// XXX need to keep shift explicitly clear for editor...
|
||||||
/*
|
/*
|
||||||
@ -61,10 +63,12 @@ var KEYBOARD_CONFIG = {
|
|||||||
_STEPS_LEFT_TO_CHANGE_DIRECTION = 2
|
_STEPS_LEFT_TO_CHANGE_DIRECTION = 2
|
||||||
}
|
}
|
||||||
nextImage()
|
nextImage()
|
||||||
|
centerRibbons()
|
||||||
},
|
},
|
||||||
// XXX nextScreenImages...
|
// XXX nextScreenImages...
|
||||||
ctrl: function(){
|
ctrl: function(){
|
||||||
nextScreenImages()
|
nextScreenImages()
|
||||||
|
centerRibbons()
|
||||||
},
|
},
|
||||||
// XXX need to keep shift explicitly clear for editor...
|
// XXX need to keep shift explicitly clear for editor...
|
||||||
/*
|
/*
|
||||||
@ -95,22 +99,42 @@ var KEYBOARD_CONFIG = {
|
|||||||
*/
|
*/
|
||||||
Home: function(){
|
Home: function(){
|
||||||
firstImage()
|
firstImage()
|
||||||
|
centerRibbons()
|
||||||
},
|
},
|
||||||
End: function(){
|
End: function(){
|
||||||
lastImage()
|
lastImage()
|
||||||
|
centerRibbons()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// combined navigation and editor actions...
|
// combined navigation and editor actions...
|
||||||
Up: {
|
Up: {
|
||||||
default: function(){ prevRibbon(DIRECTION) },
|
default: function(){
|
||||||
shift: function(){ shiftImageUp(null, DIRECTION) },
|
prevRibbon(DIRECTION)
|
||||||
'ctrl+shift': function(){ shiftImageUpNewRibbon(null, DIRECTION) },
|
centerRibbons()
|
||||||
|
},
|
||||||
|
shift: function(){
|
||||||
|
shiftImageUp(null, DIRECTION)
|
||||||
|
centerRibbons()
|
||||||
|
},
|
||||||
|
'ctrl+shift': function(){
|
||||||
|
shiftImageUpNewRibbon(null, DIRECTION)
|
||||||
|
centerRibbons()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Down: {
|
Down: {
|
||||||
default: function(){ nextRibbon(DIRECTION) },
|
default: function(){
|
||||||
shift: function(){ shiftImageDown(null, DIRECTION) },
|
nextRibbon(DIRECTION)
|
||||||
'ctrl+shift': function(){ shiftImageDownNewRibbon(null, DIRECTION) },
|
centerRibbons()
|
||||||
|
},
|
||||||
|
shift: function(){
|
||||||
|
shiftImageDown(null, DIRECTION)
|
||||||
|
centerRibbons()
|
||||||
|
},
|
||||||
|
'ctrl+shift': function(){
|
||||||
|
shiftImageDownNewRibbon(null, DIRECTION)
|
||||||
|
centerRibbons()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +154,10 @@ var KEYBOARD_CONFIG = {
|
|||||||
|
|
||||||
// XXX this is temporary, combine this with single image mode...
|
// XXX this is temporary, combine this with single image mode...
|
||||||
// XXX this should only work on single image mode...
|
// XXX this should only work on single image mode...
|
||||||
F: function(){ toggleImageProportions() },
|
F: function(){
|
||||||
|
toggleImageProportions()
|
||||||
|
centerRibbons()
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// marking...
|
// marking...
|
||||||
@ -196,7 +223,10 @@ var KEYBOARD_CONFIG = {
|
|||||||
ctrl: function(){ removeImageMarks('ribbon') },
|
ctrl: function(){ removeImageMarks('ribbon') },
|
||||||
shift: function(){ removeImageMarks('all') },
|
shift: function(){ removeImageMarks('all') },
|
||||||
},
|
},
|
||||||
F2: function(){ toggleMarkedOnlyView() },
|
F2: function(){
|
||||||
|
toggleMarkedOnlyView()
|
||||||
|
centerRibbons()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user