Put it on the Forge :) On Sun, Feb 6, 2011 at 6:08 PM, stratboy <[email protected]> wrote:
> Done. It works :) Thank you Arieh+Rolf > > If you think it will be useful for you, you can pick up my class from > the example. It's an image preloader that works like this: > > 1. You build your page as always, and put your images as always with > img tags > > 2. Instantiate the class, pass the parent of the images. Not > necessarily the immediate parent, but the class will pick all the > images inside, at every level. > > 3. The class will stop the natural image loading by setting their src > to ''. > > 4. The class will suck the source of every image, as well as the > parent and the previous sibling and save them to an array. > > 5. The class will substitute all the images each with a placeholder, > at the exact position of the original image. The placeholder will have > display:block if the original image had it, or display:inline-block > (properly hacked for ie7) if it was a regular inline image. Every > image will then be destroyed. Eventually (se options) the > placeholder's background will be setted with a spinner gif or so.. > > 6. The class will sequentially load the images and progressively > substitute the relative placeholders with them, with a nice fade-in > fx. The placeholders will then be destroyed. > > Enjoy and thank you again :) > > > > > > > On 6 Feb, 13:21, stratboy <[email protected]> wrote: > > Ok I'll do. Thank you :) > > > > On 6 Feb, 10:12, אריה גלזר <[email protected]> wrote: > > > > > I'm with rolf on this - this is almost certenly a page cache issue. add > a > > > timestamp param to the img url and see if it fixes the issue > > > > > On Sun, Feb 6, 2011 at 9:33 AM, stratboy <[email protected]> wrote: > > > > I think jsfiddle is not necessary here, and I don't have much time to > > > > setup a jsfiddle entry. > > > > I think I'm just doing something wrong in the code and I can't find > > > > the error. > > > > Once upon a time a programmed page link was enough.. :P > > > > I'll go for another way maybe. > > > > > > Thank you anyway > > > > > > On 5 Feb, 14:00, Rolf -nl <[email protected]> wrote: > > > > > can you put up the example code at jsfiddle? > > > > > can you add a random id or a timestamp to the images so that the > > > > > images aren't cached, its easier testing that way else images are > 304 > > > > > not modified after 1 test etc. > > > > > > > On Feb 4, 10:29 pm, stratboy <[email protected]> wrote: > > > > > > > > Not strange enough? :))) > > > > > > > > On 4 Feb, 11:26, stratboy <[email protected]> wrote: > > > > > > > > > This is even more strange: > > > > > > > > >http://reghellin.com/debug/image-preloader/ > > > > > > > > > here the relevant code: > > > > > > > > > prepare:function(){ > > > > > > > this.images = > this.image_box.getElements('img'); > > > > > > > this.images.each(function(image,index){ > > > > > > > > > this.data.push({image:image, > > > > src:image.get('src')}); > > > > > > > image.set({ > > > > > > > 'src':'', > > > > > > > 'styles':{ > > > > > > > //'opacity':0, > > > > > > > //'visibility':'hidden' > > > > > > > } > > > > > > > }); > > > > > > > },this); > > > > > > > }, > > > > > > > > > load_image:function(){ > > > > > > > var img = new > > > > Asset.image(this.data[this.image_index].src, { > > > > > > > onLoad:function(img_tag){ > > > > > > > $(document.body).innerHTML += > > > > img_tag.get('src')+'<br>' > > > > > > > var data = > > > > this.data[this.image_index]; > > > > > > > data.image.set('src',data.src); > > > > > > > console.log(data.image); > > > > > > > > > this.image_index += 1; > > > > > > > > > if(this.image_index < > > > > this.data.length){ > > > > > > > this.load_image(); > > > > > > > } > > > > > > > }.bind(this)//fine onLoad > > > > > > > });//fine asset > > > > > > > }, > > > > > > > > > in prepare() I fill the data array with the images and strip > out the > > > > > > > src prop to stop the browser natural loading process. ok. > > > > > > > > > in load_image, onLoad, I set the src prop again. It does, but.. > Not > > > > in > > > > > > > on the window.images.. It seems as I filled the array with a > copy of > > > > > > > the images instead of the images themselves. More, If i, from > onLoad, > > > > > > > try to reference the images direcly, like: > > > > > > > > > $('image-box').getElements('img')[0].setStyle('border','1px > solid > > > > > > > #ff0000') > > > > > > > > > it won't work!!! Uh??? > > > > > > > > > Any idea? :( > > > > > -- > > > Arieh Glazer > > > אריה גלזר > > > 052-5348-561http://www.arieh.co.ilhttp://www.link-wd.co.il > -- Arieh Glazer אריה גלזר 052-5348-561 http://www.arieh.co.il http://www.link-wd.co.il
