goffgrafix / galleriffic

Automatically exported from code.google.com/p/galleriffic
0 stars 0 forks source link

Duplicate element when i use gotoImage #84

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
$.galleriffic.gotoImage('#id_image');

i have two images if the #id_image if the first image in gallery

I'm using gallerific 2.0

what's i'm doing wrong?? if i try to load an imagen using the url it
doesn't work, help me please!! i'm using galleriffic with Django. Sorry for
my english 

Original issue reported on code.google.com by helm...@gmail.com on 26 Jan 2010 at 4:25

GoogleCodeExporter commented 9 years ago
I'm not sure but I believe it has to do with the history plugin. 
For me removing the  $.galleriffic.gotoImage(hash); on the pageload function 
cleared out this problem for me. 

  function pageload(hash) {
  // hash doesn't contain the first # character.
    if (hash) {
       //    $.galleriffic.gotoImage(hash);
     } else {                                                                  
              gallery.gotoIndex(0);
     }
    }

Original comment by deleon...@gmail.com on 21 Sep 2010 at 1:50

GoogleCodeExporter commented 9 years ago
I agree. It has to do with the combination of galleriffic and the use of the 
history plugin.

But your solution won't work. When you remove the if-branche, you still have 
duplicates but the gallery won't work correctly anymore.

Instead you should remove the else-branch (gallery.gotoIndex(0);) --> you won't 
have duplicates and the gallery will work correctly BUT you still have one 
small problem: the initial page load isn't registered correctly in the history 
plugin. That means, if you hit the back-button till you reach the first call to 
the page, the first image won't be loaded. Instead you will see still the 
second picture you've watched.

I believe, that the problem is anywhere inside of the refresh() method, that it 
can't deal correctly with parallel calls: galleriffic initializes the first 
image and bypasses the history plugin and very soon after that, the history 
plugin itself is initialized and calls "gallery.gotoIndex(0)" in the else 
branch. I'm absolutely sure, that these two immediate calls cause the problem.

In my eyes, it shouldn't be necessary to load the image twice upon page load. 
So I tried to remove the else-branch in the history pageload function and 
change line 931 of galleriffic plugin from

this.gotoIndex(0, false, true);

to

this.gotoIndex(0, false, false);

If the third parameter is set to true, it will bypass the history plugin. But 
changing the parameter to false causes an error within the history plugin. I 
guess, that it isn't initialized at this moment. If we would have a possibility 
to initialize the history plugin with the hash of the first image without 
calling the galleriffic function to load the page, we could prevent the 
duplicate problem. (But there would be still the sync-problem inside of 
galleriffic)

Original comment by andreas....@gmail.com on 1 Oct 2010 at 8:07

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've fixed it for myself with the addition of two lines to the gotoIndex() 
function, as seen on lines 13-14 here: https://gist.github.com/1050349

I realized that galleriffic's "hash" is not the same as "grab the stuff after 
the octothorpe in the current URL", and thus was able to add an appropriate 
condition.

Original comment by simmerde...@gmail.com on 28 Jun 2011 at 2:19