Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:42:29+00:00 2026-06-15T09:42:29+00:00

This is a massive conundrum for me. I will explain in full. I normally

  • 0

This is a massive conundrum for me. I will explain in full.

I normally simply fire the fancyapps fancybox plugin like this…

$("a.gallery-thumb").fancybox({

    afterLoad   : function() {

        /* shtuff */

    }

});

But I need to pass a unquique varible when the a.gallery-thumb is clicked. This unique varible is generated using this…

FB.Canvas.getPageInfo(function(info) {

    var scrollPosition = info.scrollTop;

};

This scrollPosition unique varible is the current scroll position when my a.gallery-thumb is clicked.

So I need to then pass the scrollPosition variable into the fancybox function below.

$("a.gallery-thumb").fancybox({

    afterLoad   : function() {

        $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');   

    }

});

Now your probably thinking why don’t I just do this…

$("a.gallery-thumb").fancybox({

    afterLoad   : function() {

        FB.Canvas.getPageInfo(function(info) {

            var scrollPosition = info.scrollTop;

            $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');   

        };            

    }

    afterShow    : function() { },
    onUpdate     : function() { }

});

OK – this works fine, but I need the scrollPosition variable in other fancybox callbacks like afterShow and onUpdate. But sure I can just repeat FB.Canvas.getPageInfo function… Not quite, I need the original generated value from when the gallery initial click was made.

So perhaps I have to do something like this, but I can’t seem to get it to work, any ideas on how I can get the below script working?

$("a.gallery-thumb").on('click', function (){

    event.preventDefault(); /* I'm trying to stop the image opening by default before my fancybox function runs */

    FB.Canvas.getPageInfo(function(info) {

        var scrollPosition = info.scrollTop;

        $(this).attr('rel','fancybox-thumb').fancybox({

            onUpdate   : function() {

                $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');

            },

            afterLoad   : function() {

                $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');

            },

            afterShow    : function() {

                $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');

            },

            onUpdate     : function() {

                $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');

            }

        });

    });

});

See js fiddle here emulating my problem of the fancybox function not firing…

[http://jsfiddle.net/svsdx/1631/][1]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:42:31+00:00Added an answer on June 15, 2026 at 9:42 am

    why not just move the variable declaration up a level so it’s in scope for the whole function? Like:

    var scrollPosition = 0;
    $("a.gallery-thumb").on('click', function (event){
    
        event.preventDefault(); /* I'm trying to stop the image opening by default before my fancybox function runs */
        FB.Canvas.getPageInfo(function(info) {
    
            scrollPosition = info.scrollTop;
        });
        return false;
        }).each(function(){
    
            $(this).attr('rel','fancybox-thumb').fancybox({             
                onUpdate   : function() {   
                    $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');           
                },                          
                afterLoad   : function() {              
                    $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');            
            },
                afterShow    : function() {
                    $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');
                },
                onUpdate     : function() {
                    $('.fancybox-wrap').css('top', '+=' + scrollPosition + 'px');
                }
            });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Disclaimer: I realize this is a massive wall of text, but I have done
This has been a massive headache. We use Ning as a our platform for
Here is a (big) example of the massive problem I am having, when this
this is my first question in here, and I would like to ask if
I have this massive nested loop scenario that is calling the DB and making
I have this massive folder structure with thousands of folders and subfolders. I need
I have this massive query that I can typically run in under 2 minutes.
I get this horrible massive error when trying to plot using matplotlib: Traceback (most
Massive apologies for this embarrassing question— I'm using my MacBook Pro, running snow leopard,
This is just a design question regarding massive db design. For instance, if you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.