mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 11:50:07 +00:00
fixed a bug in jli.getElementOrigin(..) that prevented it from returning negative values...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
efcbea5b18
commit
96ae34b70f
@ -88,7 +88,6 @@ function setScale(s){
|
|||||||
// The goal of the experiment is to make this do it's thing without
|
// The goal of the experiment is to make this do it's thing without
|
||||||
// changing element's screen position
|
// changing element's screen position
|
||||||
//
|
//
|
||||||
// XXX this does not work of position is negative...
|
|
||||||
function setOrigin(l, t, no_comp){
|
function setOrigin(l, t, no_comp){
|
||||||
var block = $('.block')
|
var block = $('.block')
|
||||||
var o = getElementOrigin(block)
|
var o = getElementOrigin(block)
|
||||||
@ -99,9 +98,6 @@ function setOrigin(l, t, no_comp){
|
|||||||
var offset = getElementOffset(block)
|
var offset = getElementOffset(block)
|
||||||
|
|
||||||
// calculate the offset change and compensate...
|
// calculate the offset change and compensate...
|
||||||
// XXX this breaks with negative values...
|
|
||||||
// - starts moving around
|
|
||||||
// - the secondary pointer goes crazy...
|
|
||||||
var cl = offset.left + ((o.left - o.left*s) - (l - l*s))
|
var cl = offset.left + ((o.left - o.left*s) - (l - l*s))
|
||||||
var ct = offset.top + ((o.top - o.top*s) - (t - t*s))
|
var ct = offset.top + ((o.top - o.top*s) - (t - t*s))
|
||||||
|
|
||||||
@ -115,21 +111,24 @@ function setOrigin(l, t, no_comp){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// center a specific point (default: origin)
|
// Center a block to a point...
|
||||||
|
//
|
||||||
|
// If not coordinates are given then center to element origin...
|
||||||
//
|
//
|
||||||
// NOTE: scale indicates the source coordinate scale, if set to 1 t and
|
// NOTE: scale indicates the source coordinate scale, if set to 1 t and
|
||||||
// l will 1:1 to screen, and if set the the same scale as the element
|
// l will 1:1 to screen, and if set to the same scale as the element
|
||||||
// then t and l will be 1:1 to the element...
|
// then t and l will be 1:1 to the element...
|
||||||
// supported keywords:
|
// supported keywords:
|
||||||
// 'screen'
|
// 'screen'
|
||||||
// 'elem'
|
// 'elem'
|
||||||
function centerBlock(l, t, scale){
|
function centerBlock(l, t, scale){
|
||||||
scale = scale == true || scale == 'screen' ? 1
|
|
||||||
: scale == 'elem' ? null
|
|
||||||
: scale
|
|
||||||
|
|
||||||
var s = getElementScale(block)
|
|
||||||
var block = $('.block')
|
var block = $('.block')
|
||||||
|
var s = getElementScale(block)
|
||||||
|
|
||||||
|
scale = scale == 'screen' ? 1
|
||||||
|
: scale == 'elem' ? s
|
||||||
|
: s
|
||||||
|
|
||||||
var offset = getElementOffset(block)
|
var offset = getElementOffset(block)
|
||||||
|
|
||||||
var bo = block.offset()
|
var bo = block.offset()
|
||||||
@ -142,14 +141,17 @@ function centerBlock(l, t, scale){
|
|||||||
|
|
||||||
// normalize the l,t to element scale...
|
// normalize the l,t to element scale...
|
||||||
if(l != null && t != null){
|
if(l != null && t != null){
|
||||||
l = scale != null ? (l/s)*scale : l
|
|
||||||
t = scale != null ? (t/s)*scale : t
|
|
||||||
|
|
||||||
var w = block.width()
|
var w = block.width()
|
||||||
var h = block.height()
|
var h = block.height()
|
||||||
o = {
|
o = {
|
||||||
top: t*s + (h - h*s) / (w / o.left),
|
// target offset scale...
|
||||||
left: l*s + (w - w*s) / (h / o.left),
|
top: t*scale
|
||||||
|
// set origin to top left corner of element (compensate
|
||||||
|
// for scaling)...
|
||||||
|
+ (h - h*s) / (w / o.left),
|
||||||
|
left: l*scale
|
||||||
|
+ (w - w*s) / (h / o.left),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -514,7 +514,7 @@ var getElementOrigin = makeCSSVendorAttrGetter(
|
|||||||
'transformOrigin',
|
'transformOrigin',
|
||||||
{top: 0, left: 0},
|
{top: 0, left: 0},
|
||||||
function(data){
|
function(data){
|
||||||
res = /([0-9.]*(px|%)) ([0-9.]*(px|%))/.exec(data)
|
res = /(-?[0-9.]*(px|%)) (-?[0-9.]*(px|%))/.exec(data)
|
||||||
return {
|
return {
|
||||||
left: res[1].slice(-2) == 'px' ? parseFloat(res[1]) : res[1],
|
left: res[1].slice(-2) == 'px' ? parseFloat(res[1]) : res[1],
|
||||||
top: res[3].slice(-2) == 'px' ? parseFloat(res[3]) : res[3],
|
top: res[3].slice(-2) == 'px' ? parseFloat(res[3]) : res[3],
|
||||||
|
|||||||
@ -417,15 +417,17 @@ actions.Actions(Client, {
|
|||||||
this.ribbons.setBaseRibbon(r)
|
this.ribbons.setBaseRibbon(r)
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// XXX need screen width in images...
|
// XXX test...
|
||||||
prevScreen: ['Focus previous image one screen width away',
|
prevScreen: ['Focus previous image one screen width away',
|
||||||
function(){
|
function(){
|
||||||
// XXX
|
var s = Math.floor(this.ribbons.getScreenWidthImages())
|
||||||
|
this.focusImage(this.data.getImage('current', -s))
|
||||||
}],
|
}],
|
||||||
// XXX need screen width in images...
|
// XXX test...
|
||||||
nextScreen: ['Focus next image one screen width away',
|
nextScreen: ['Focus next image one screen width away',
|
||||||
function(){
|
function(){
|
||||||
// XXX
|
var s = Math.floor(this.ribbons.getScreenWidthImages())
|
||||||
|
this.focusImage(this.data.getImage('current', s))
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// zooming...
|
// zooming...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user