mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 19:00:09 +00:00
fixed most of the alignment problems (turned out to be what I expected for a weeK but was to lazy to test spending 7 days instead of 7 minutes fixing -- default transform origin is relative (50% 50% 0) and thus position is affected by element (ribbon-set) size)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
23f7936d9e
commit
1e42a0dd39
@ -407,12 +407,23 @@ function loadData(data, images_per_screen){
|
|||||||
* Setup
|
* Setup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Setup event handlers for data bindings...
|
||||||
|
//
|
||||||
|
// This does two jobs:
|
||||||
|
// - maintain DATA state
|
||||||
|
// - editor actions
|
||||||
|
// - focus
|
||||||
|
// - marking
|
||||||
|
// - maintain view consistency
|
||||||
|
// - centering/moving (roll)
|
||||||
|
// - shifting (expand/contract)
|
||||||
|
// - zooming (expand/contract)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// XXX this is causing lots of errors, rethink...
|
||||||
function setupDataBindings(viewer){
|
function setupDataBindings(viewer){
|
||||||
viewer = viewer == null ? $('.viewer') : viewer
|
viewer = viewer == null ? $('.viewer') : viewer
|
||||||
viewer
|
viewer
|
||||||
// XXX this causes miss-aligns after shifting and/or zooming...
|
|
||||||
// ...after zooming, moving focus causes the screen to align
|
|
||||||
// in an odd way until the next move corrects the issue...
|
|
||||||
// XXX need to maintain the correct number of images per ribbon
|
// XXX need to maintain the correct number of images per ribbon
|
||||||
// per zoom setting -- things get really odd when a ribbon
|
// per zoom setting -- things get really odd when a ribbon
|
||||||
// is smaller than it should be...
|
// is smaller than it should be...
|
||||||
|
|||||||
@ -309,7 +309,6 @@ function extendRibbon(left, right, ribbon, no_compensate_shift){
|
|||||||
left: $([]),
|
left: $([]),
|
||||||
right: $([])
|
right: $([])
|
||||||
}
|
}
|
||||||
var pre = getRelativeVisualPosition($('.viewer'), ribbon).left
|
|
||||||
|
|
||||||
// truncate...
|
// truncate...
|
||||||
// NOTE: we save the detached elements to reuse them on extending,
|
// NOTE: we save the detached elements to reuse them on extending,
|
||||||
@ -332,24 +331,13 @@ function extendRibbon(left, right, ribbon, no_compensate_shift){
|
|||||||
|
|
||||||
// NOTE: this is fool-proof as it's based on relative visual
|
// NOTE: this is fool-proof as it's based on relative visual
|
||||||
// position...
|
// position...
|
||||||
var position_updated = false
|
|
||||||
var post = getRelativeVisualPosition($('.viewer'), ribbon).left
|
|
||||||
var scale = getElementScale($('.ribbon-set'))
|
var scale = getElementScale($('.ribbon-set'))
|
||||||
var l = parseFloat(ribbon.css('left'))
|
var l = parseFloat(ribbon.css('left'))
|
||||||
l = isNaN(l) ? 0 : l
|
l = isNaN(l) ? 0 : l
|
||||||
// compensate for positioning errors...
|
|
||||||
// XXX not sure where these come from, when the scale is != 0...
|
|
||||||
if(pre != post){
|
|
||||||
position_updated = true
|
|
||||||
l = l + (pre - post)/scale
|
|
||||||
}
|
|
||||||
// compensate for left shift...
|
// compensate for left shift...
|
||||||
if(!no_compensate_shift && left != 0){
|
if(!no_compensate_shift && left != 0){
|
||||||
position_updated = true
|
|
||||||
l -= left * images.outerWidth()
|
l -= left * images.outerWidth()
|
||||||
}
|
|
||||||
// write the position...
|
|
||||||
if(position_updated){
|
|
||||||
ribbon.css({
|
ribbon.css({
|
||||||
left: l,
|
left: l,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -22,6 +22,13 @@
|
|||||||
|
|
||||||
.ribbon-set {
|
.ribbon-set {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
/* neede for scaling/zooming to behave correctly and not shift the
|
||||||
|
element, when its dimensions change... */
|
||||||
|
transform-origin: top left;
|
||||||
|
-ms-transform-origin: top left;
|
||||||
|
-webkit-transform-origin: top left; /* Safari and Chrome */
|
||||||
}
|
}
|
||||||
.ribbon-set:empty:after {
|
.ribbon-set:empty:after {
|
||||||
display: block;
|
display: block;
|
||||||
@ -232,6 +239,8 @@
|
|||||||
// setup...
|
// setup...
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|
||||||
|
//setElementOrigin($('.ribbon-set'), 'top', 'left')
|
||||||
|
|
||||||
loadData(DATA)
|
loadData(DATA)
|
||||||
|
|
||||||
// NOTE: this is global so as to not to add any extra complexity to
|
// NOTE: this is global so as to not to add any extra complexity to
|
||||||
|
|||||||
@ -499,11 +499,26 @@ function setElementScale(elem, scale){
|
|||||||
return setElementTransform(elem, null, scale)
|
return setElementTransform(elem, null, scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setElementOrigin(elem, x, y, z){
|
||||||
|
x = x == null ? '50%' : x
|
||||||
|
y = y == null ? '50%' : y
|
||||||
|
z = z == null ? '0' : z
|
||||||
|
var value = x +' '+ y +' '+ z
|
||||||
|
|
||||||
|
return $(elem).css({
|
||||||
|
'transform-origin': value,
|
||||||
|
'-ms-transform-origin': value,
|
||||||
|
'-webkit-transform-origin': value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function setTransitionEasing(elem, ease){
|
function setTransitionEasing(elem, ease){
|
||||||
if(typeof(ms) == typeof(0)){
|
if(typeof(ms) == typeof(0)){
|
||||||
ms = ms + 'ms'
|
ms = ms + 'ms'
|
||||||
}
|
}
|
||||||
return elem.css({
|
return $(elem).css({
|
||||||
'transition-timing-function': ease,
|
'transition-timing-function': ease,
|
||||||
'-moz-transition-timing-function': ease,
|
'-moz-transition-timing-function': ease,
|
||||||
'-o-transition-timing-function': ease,
|
'-o-transition-timing-function': ease,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user