mirror of
https://github.com/flynx/ImageGrid.git
synced 2026-01-10 20:27:44 +00:00
minor bugfix + made the zoom relative to current scale rather than to the fixed image size...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
29513fb909
commit
f619e62658
@ -286,7 +286,7 @@ function shiftImage(direction, image, force_create_ribbon){
|
|||||||
// need to create a new ribbon...
|
// need to create a new ribbon...
|
||||||
if(ribbon.length == 0 || force_create_ribbon == true){
|
if(ribbon.length == 0 || force_create_ribbon == true){
|
||||||
var index = getRibbonIndex(old_ribbon)
|
var index = getRibbonIndex(old_ribbon)
|
||||||
index = direction == 'after' ? index + 1 : index
|
index = direction == 'next' ? index + 1 : index
|
||||||
|
|
||||||
ribbon = createRibbon(index)
|
ribbon = createRibbon(index)
|
||||||
|
|
||||||
@ -888,6 +888,9 @@ function nextImage(n, mode){
|
|||||||
var target = $('.current.image').nextAll('.image' + mode)
|
var target = $('.current.image').nextAll('.image' + mode)
|
||||||
if(target.length < n){
|
if(target.length < n){
|
||||||
target = target.last()
|
target = target.last()
|
||||||
|
// XXX BUG this fires we hit the end of the currently loaded
|
||||||
|
// images while scrolling very fast rather than when we are
|
||||||
|
// out of images in the current ribbon...
|
||||||
flashIndicator('end')
|
flashIndicator('end')
|
||||||
} else {
|
} else {
|
||||||
target = target.eq(n-1)
|
target = target.eq(n-1)
|
||||||
@ -900,6 +903,9 @@ function prevImage(n, mode){
|
|||||||
var target = $('.current.image').prevAll('.image' + mode)
|
var target = $('.current.image').prevAll('.image' + mode)
|
||||||
if(target.length < n){
|
if(target.length < n){
|
||||||
target = target.last()
|
target = target.last()
|
||||||
|
// XXX BUG this fires we hit the end of the currently loaded
|
||||||
|
// images while scrolling very fast rather than when we are
|
||||||
|
// out of images in the current ribbon...
|
||||||
flashIndicator('start')
|
flashIndicator('start')
|
||||||
} else {
|
} else {
|
||||||
target = target.eq(n-1)
|
target = target.eq(n-1)
|
||||||
@ -980,6 +986,9 @@ function nextRibbon(moving, mode){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************* Zooming ***/
|
||||||
|
|
||||||
function fitNImages(n){
|
function fitNImages(n){
|
||||||
var image = $('.current.image')
|
var image = $('.current.image')
|
||||||
var size = image.outerHeight(true)
|
var size = image.outerHeight(true)
|
||||||
@ -996,19 +1005,21 @@ function fitNImages(n){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var MAX_SCREEN_IMAGES = 10
|
var MAX_SCREEN_IMAGES = 12
|
||||||
|
var ZOOM_SCALE = 1.2
|
||||||
|
|
||||||
// XXX use the actual scale...
|
|
||||||
function zoomIn(){
|
function zoomIn(){
|
||||||
var w = getScreenWidthInImages()
|
var w = getScreenWidthInImages()
|
||||||
if(w > 1){
|
if(w > 1){
|
||||||
fitNImages(w-1)
|
w = w / ZOOM_SCALE
|
||||||
|
fitNImages(w >= 1 ? w : 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function zoomOut(){
|
function zoomOut(){
|
||||||
var w = getScreenWidthInImages()
|
var w = getScreenWidthInImages()
|
||||||
if(w <= MAX_SCREEN_IMAGES){
|
if(w <= MAX_SCREEN_IMAGES){
|
||||||
fitNImages(w+1)
|
w = w * ZOOM_SCALE
|
||||||
|
fitNImages(w <= MAX_SCREEN_IMAGES ? w : MAX_SCREEN_IMAGES)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1016,6 +1027,8 @@ function zoomOut(){
|
|||||||
|
|
||||||
/************************************************** Editor Actions ***/
|
/************************************************** Editor Actions ***/
|
||||||
|
|
||||||
|
// XXX shifting down from the main ribbon kills the app (infinite loop?)
|
||||||
|
// ...appears to be a problem with creating a new ribbon below...
|
||||||
function shiftImageTo(image, direction, moving, force_create_ribbon, mode){
|
function shiftImageTo(image, direction, moving, force_create_ribbon, mode){
|
||||||
if(image == null){
|
if(image == null){
|
||||||
image = $('.current.image')
|
image = $('.current.image')
|
||||||
|
|||||||
@ -251,6 +251,7 @@ $(function(){
|
|||||||
|
|
||||||
|
|
||||||
// dynamic loading...
|
// dynamic loading...
|
||||||
|
if(true){
|
||||||
// XXX move to a setup function in the lib...
|
// XXX move to a setup function in the lib...
|
||||||
// XXX update this depending on zoom and navigation speed...
|
// XXX update this depending on zoom and navigation speed...
|
||||||
var LOADER_THRESHOLD = 2
|
var LOADER_THRESHOLD = 2
|
||||||
@ -310,7 +311,7 @@ $(function(){
|
|||||||
var ribbon = to
|
var ribbon = to
|
||||||
to = getRibbonIndex(to)
|
to = getRibbonIndex(to)
|
||||||
|
|
||||||
var gid = JSON.parse(image.attr('gid'))
|
var gid = getImageGID(image)
|
||||||
|
|
||||||
var index = DATA.ribbons[from].indexOf(gid)
|
var index = DATA.ribbons[from].indexOf(gid)
|
||||||
var img = DATA.ribbons[from].splice(index, 1)
|
var img = DATA.ribbons[from].splice(index, 1)
|
||||||
@ -330,6 +331,29 @@ $(function(){
|
|||||||
console.log('removing ribbon...')
|
console.log('removing ribbon...')
|
||||||
DATA.ribbons.splice(index, 1)
|
DATA.ribbons.splice(index, 1)
|
||||||
})
|
})
|
||||||
|
.on('requestedFirstImage', function(evt, ribbon){
|
||||||
|
var r = getRibbonIndex(ribbon)
|
||||||
|
|
||||||
|
// XXX this result in an infinite loop somewhere...
|
||||||
|
//var target = DATA.ribbons[r][0]
|
||||||
|
//
|
||||||
|
//loadImages(target, 30, ribbon)
|
||||||
|
|
||||||
|
var gr = DATA.ribbons[r]
|
||||||
|
rollImages(-gr.length, ribbon)
|
||||||
|
})
|
||||||
|
.on('requestedLastImage', function(evt, ribbon){
|
||||||
|
var r = getRibbonIndex(ribbon)
|
||||||
|
|
||||||
|
// XXX this result in an infinite loop somewhere...
|
||||||
|
//var target = DATA.ribbons[r][DATA.ribbons[r].length-1]
|
||||||
|
//
|
||||||
|
//loadImages(target, 30, ribbon)
|
||||||
|
|
||||||
|
var gr = DATA.ribbons[r]
|
||||||
|
rollImages(gr.length, ribbon)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user