mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
fixed an align bug...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
47f1007a49
commit
7a7641c2fc
@ -101,6 +101,7 @@ function updateImageProportions(){
|
|||||||
// change proportions...
|
// change proportions...
|
||||||
if(c < threshold){
|
if(c < threshold){
|
||||||
var images = viewer.find('.ribbon .image')
|
var images = viewer.find('.ribbon .image')
|
||||||
|
|
||||||
var W = viewer.width()
|
var W = viewer.width()
|
||||||
var H = viewer.height()
|
var H = viewer.height()
|
||||||
|
|
||||||
@ -121,6 +122,9 @@ function updateImageProportions(){
|
|||||||
// new size...
|
// new size...
|
||||||
var n = di + d
|
var n = di + d
|
||||||
|
|
||||||
|
// the amount to compensate ribbon offset for per image...
|
||||||
|
var x = n - dm
|
||||||
|
|
||||||
|
|
||||||
if(n == dm){
|
if(n == dm){
|
||||||
return
|
return
|
||||||
@ -160,10 +164,6 @@ function updateImageProportions(){
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// XXX for some reason this is not working correctly...
|
|
||||||
//that.alignRibbons()
|
|
||||||
//that.ribbons.restoreTransitions(true)
|
|
||||||
|
|
||||||
that.ribbons
|
that.ribbons
|
||||||
.centerImage()
|
.centerImage()
|
||||||
.restoreTransitions(true)
|
.restoreTransitions(true)
|
||||||
@ -275,6 +275,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
|
|||||||
var pre_state = this.toggleSingleImage('?')
|
var pre_state = this.toggleSingleImage('?')
|
||||||
|
|
||||||
return function(){
|
return function(){
|
||||||
|
var that = this
|
||||||
var state = this.toggleSingleImage('?')
|
var state = this.toggleSingleImage('?')
|
||||||
|
|
||||||
// singe image mode -- set image proportions...
|
// singe image mode -- set image proportions...
|
||||||
@ -290,6 +291,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
// ribbon mode -- restore original image size...
|
// ribbon mode -- restore original image size...
|
||||||
} else {
|
} else {
|
||||||
|
// reset image container size...
|
||||||
this.ribbons.viewer.find('.image:not(.clone)')
|
this.ribbons.viewer.find('.image:not(.clone)')
|
||||||
.each(function(_, img){
|
.each(function(_, img){
|
||||||
img.style.width = ''
|
img.style.width = ''
|
||||||
@ -298,9 +300,8 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
|
|||||||
img.style.margin = ''
|
img.style.margin = ''
|
||||||
})
|
})
|
||||||
|
|
||||||
this.ribbons.centerImage()
|
// align ribbons...
|
||||||
|
this.alignRibbons('now')
|
||||||
// XXX need to correctly align other ribbons...
|
|
||||||
|
|
||||||
// update scale...
|
// update scale...
|
||||||
if(state != pre_state){
|
if(state != pre_state){
|
||||||
|
|||||||
@ -337,7 +337,12 @@ module.ViewerActions = actions.Actions({
|
|||||||
// order...
|
// order...
|
||||||
// XXX skip off-screen ribbons (???)
|
// XXX skip off-screen ribbons (???)
|
||||||
alignByOrder: ['Interface/Align ribbons by image order',
|
alignByOrder: ['Interface/Align ribbons by image order',
|
||||||
function(target){
|
function(target, scale, now){
|
||||||
|
if(target == 'now'){
|
||||||
|
now = true
|
||||||
|
target = null
|
||||||
|
}
|
||||||
|
|
||||||
var ribbons = this.ribbons
|
var ribbons = this.ribbons
|
||||||
var data = this.data
|
var data = this.data
|
||||||
|
|
||||||
@ -351,16 +356,11 @@ module.ViewerActions = actions.Actions({
|
|||||||
// data into ribbons based on target gid... i.e. first
|
// data into ribbons based on target gid... i.e. first
|
||||||
// we know the section we need then align it vertically...
|
// we know the section we need then align it vertically...
|
||||||
this
|
this
|
||||||
.centerImage(gid)
|
.centerImage(gid, null, null, scale)
|
||||||
.centerRibbon(gid)
|
.centerRibbon(gid, null, null, scale)
|
||||||
|
|
||||||
// if we are going fast we might skip an update...
|
|
||||||
if(this._align_timeout != null){
|
|
||||||
clearTimeout(this._align_timeout)
|
|
||||||
this._align_timeout = null
|
|
||||||
}
|
|
||||||
var that = this
|
var that = this
|
||||||
this._align_timeout = setTimeout(function(){
|
var _align = function(){
|
||||||
this._align_timeout = null
|
this._align_timeout = null
|
||||||
// align other ribbons...
|
// align other ribbons...
|
||||||
var ribbon = data.getRibbon(gid)
|
var ribbon = data.getRibbon(gid)
|
||||||
@ -381,15 +381,29 @@ module.ViewerActions = actions.Actions({
|
|||||||
if(f == null){
|
if(f == null){
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
that.centerImage(f, 'before')
|
that.centerImage(f, 'before', null, scale)
|
||||||
} else {
|
} else {
|
||||||
that.centerImage(t, 'after')
|
that.centerImage(t, 'after', null, scale)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 50)
|
}
|
||||||
|
|
||||||
|
if(now){
|
||||||
|
_align()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// if we are going fast we might skip an update...
|
||||||
|
if(this._align_timeout != null){
|
||||||
|
clearTimeout(this._align_timeout)
|
||||||
|
this._align_timeout = null
|
||||||
|
}
|
||||||
|
this._align_timeout = setTimeout(_align, 50)
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
alignByFirst: ['Interface/Align ribbons except current to first image',
|
alignByFirst: ['Interface/Align ribbons except current to first image',
|
||||||
function(target){
|
function(target){
|
||||||
|
target = target == 'now' ? null : target
|
||||||
|
|
||||||
var ribbons = this.ribbons
|
var ribbons = this.ribbons
|
||||||
var data = this.data
|
var data = this.data
|
||||||
|
|
||||||
@ -431,13 +445,13 @@ module.ViewerActions = actions.Actions({
|
|||||||
// NOTE: this will align only a single image...
|
// NOTE: this will align only a single image...
|
||||||
// XXX do we need these low level primitives here???
|
// XXX do we need these low level primitives here???
|
||||||
centerImage: ['- Interface/Center an image in ribbon horizontally',
|
centerImage: ['- Interface/Center an image in ribbon horizontally',
|
||||||
function(target, align){
|
function(target, align, offset, scale){
|
||||||
target = target instanceof jQuery
|
target = target instanceof jQuery
|
||||||
? this.ribbons.getElemGID(target)
|
? this.ribbons.getElemGID(target)
|
||||||
: target
|
: target
|
||||||
|
|
||||||
// align current ribbon...
|
// align current ribbon...
|
||||||
this.ribbons.centerImage(target, align)
|
this.ribbons.centerImage(target, align, offset, scale)
|
||||||
}],
|
}],
|
||||||
centerRibbon: ['- Interface/Center a ribbon vertically',
|
centerRibbon: ['- Interface/Center a ribbon vertically',
|
||||||
function(target){
|
function(target){
|
||||||
@ -1565,22 +1579,26 @@ module.AutoAlignRibbons = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
actions: actions.Actions({
|
actions: actions.Actions({
|
||||||
alignRibbons: ['Interface/Align ribbons',
|
alignRibbons: ['Interface/Align ribbons',
|
||||||
function(){
|
function(target, scale, now){
|
||||||
|
if(target == 'now'){
|
||||||
|
now = true
|
||||||
|
target = null
|
||||||
|
}
|
||||||
var mode = this.config['ribbon-align-mode']
|
var mode = this.config['ribbon-align-mode']
|
||||||
|| this.config['ribbon-focus-mode']
|
|| this.config['ribbon-focus-mode']
|
||||||
|
|
||||||
if(mode == 'visual' || mode == 'order'){
|
if(mode == 'visual' || mode == 'order'){
|
||||||
this.alignByOrder()
|
this.alignByOrder(target, scale, now)
|
||||||
|
|
||||||
} else if(mode == 'first'){
|
} else if(mode == 'first'){
|
||||||
this.alignByFirst()
|
this.alignByFirst(target, scale, now)
|
||||||
|
|
||||||
// manual...
|
// manual...
|
||||||
// XXX is this correct???
|
// XXX is this correct???
|
||||||
} else {
|
} else {
|
||||||
this
|
this
|
||||||
.centerRibbon()
|
.centerRibbon(target, null, null, scale)
|
||||||
.centerImage()
|
.centerImage(target, null, null, scale)
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
toggleRibbonAlignMode : ['Interface/Toggle ribbon align mode',
|
toggleRibbonAlignMode : ['Interface/Toggle ribbon align mode',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user