added data loading, still problems with aligning...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-12 18:29:16 +04:00
parent 970c772c52
commit 23c9736376
2 changed files with 16 additions and 21 deletions

View File

@ -635,13 +635,18 @@ function loadImagesAround(ref_gid, count, ribbon){
}
var LOAD_SCREENS = 2
var LOAD_THRESHOLD = 1
var DEFAULT_SCREEN_IMAGES = 5
function loadData(data){
function loadData(data, images_per_screen){
var ribbons_set = $('.ribbon-set')
var current = data.current
// XXX will this work without any images loaded?
var w = getScreenWidthInImages()
// if no width is given, use the current or default...
var w = images_per_screen == null ? getScreenWidthInImages() : images_per_screen
w = w > MAX_SCREEN_IMAGES ? DEFAULT_SCREEN_IMAGES : w
// clear data...
$('.ribbon').remove()
// create ribbons...
@ -656,6 +661,7 @@ function loadData(data){
focusImage($('.image').filter('[gid='+JSON.stringify(current)+']'))
fitNImages(w)
centerRibbons('css')
}
@ -774,6 +780,7 @@ function toggleImageProportions(mode){
function focusImage(image){
image.closest('.viewer').find('.current.image').removeClass('current')
$('.viewer').trigger('focusingImage', [image])
return image.addClass('current')
}

View File

@ -231,21 +231,8 @@
// setup...
$(function(){
// populate the viewer...
var r = createRibbon()
var images = []
for(var i=0; i < 40; i++){
images.push(createImage().text(i)[0])
}
r.append($(images))
//var rr = r.clone()
//var rrr = r.clone()
loadData(DATA)
// XXX use something like loadImages()...
$('.ribbon-set')
.append(r)
//.append(rr)
//.append(rrr)
// NOTE: this is global so as to not to add any extra complexity to
// the internal workings...
@ -264,10 +251,6 @@ $(function(){
if(DYNAMIC_LOADING){
// XXX move to a setup function in the lib...
// XXX update this depending on zoom and navigation speed...
LOAD_SCREENS = 2
// XXX update this depending on zoom and navigation speed...
LOAD_THRESHOLD = 1
$('.viewer')
// XXX still some times does not load the needed ribbon section
// on the first try...
@ -322,6 +305,7 @@ $(function(){
*/
})
/*
// XXX BUGGY...
.on('centeringRibbon', function(evt, ribbon, image){
// check if we are in the right range...
var gid = getImageGID(image)
@ -402,6 +386,10 @@ $(function(){
.on('fittingImages', function(evt, n){
updateImages()
})
.on('focusingImage', function(evt, image){
DATA.current = getImageGID($(image))
})
}