8000 gallery.goToPage() · Issue #44 · cubiq/SwipeView · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gallery.goToPage() #44 8000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
agdm opened this issue Feb 12, 2013 · 2 comments
Open

gallery.goToPage() #44

agdm opened this issue Feb 12, 2013 · 2 comments

Comments

@agdm
Copy link
agdm commented Feb 12, 2013

After matching a part of the url with an element in json, I get an index of that particular slide.
The problem is calling gallery.goToPage() on that index...
It always seems to just load the second slide during normal execution but if I use the console, I can go directly to the slide using that function.

Ex: lets say the index is 31... it goes to slide num:2.

The only clue I have is that upcoming == "311" if my index is 31 which seems like a type error. This variable is set in gallery.onFlip();

All I need to do is call goToPage on load and have it execute properly.

code

// if slide alias is in thePath
            var thePath = document.location.pathname
            var firstSlideAlias = thePath.substring(thePath.lastIndexOf('/'), thePath.length);

            //conforms to a path with an gallery or slide alias appended
            if (  (thePath.match(/\//g)||[]).length === 5 ) {

                if ( firstSlideAlias.length > 1 ) {
                    firstSlideAlias = firstSlideAlias.replace('/','');  
                    for (var i in slides) {
                            if ( firstSlideAlias === slides[i].alias ) {
                                console.log(firstSlideAlias);
                                console.log(slides[i].alias);
                                slideIndex = i;
                            }
                    }

                    console.log(slides[slideIndex]);
                    console.log(slideIndex);
                    gallery.goToPage(slideIndex);

                } 


            }
@agdm
Copy link
Author
agdm commented Feb 13, 2013

fixed by wrapping in setTimeout()

if (  (thePath.match(/\//g)||[]).length === 5 ) {               
    if ( firstSlideAlias.length > 1 ) {
        firstSlideAlias = firstSlideAlias.replace('/','');  
        for (var i in slides) {
                if ( firstSlideAlias === slides[i].alias ) {
                    slideIndex = i;
                    setTimeout(function(){
                        gallery.goToPage(slideIndex);
                    }, 100);
                }
        }
    } 
}

@arlg
Copy link
arlg commented Jul 24, 2013

Had the same issue, and was a mistake from me.
Be sure to pass a number to the goToPage() method, or convert your string to Int ( parseInt( (yourIndex) , 10);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0