Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjusting the position of FB.ui() dialog box

I'm using Fb.ui() to post an update to user's wall but the dialog always appears in the same spot in my browser (center middle if scrolled up). The problem is that I'm opening the dialog from the bottom of the screen. Is there a way to get the dialog to show for the user's current scroll location?

like image 784
jorilallo Avatar asked Dec 20 '10 13:12

jorilallo


2 Answers

The FB.ui() dialog should already be positionned relative to the place the user scroll currently is.

If not, you can simply position your #fb-root in CSS :

#fb-root { position:fixed; top:10%; }

That way, the pop-in will always be on the scroll position of the user and also follow it if he continue to scroll up or down the page.

like image 115
Julien Augereau Avatar answered Sep 21 '22 21:09

Julien Augereau


I'm using this piece of code to set the dialog position to the top of the page, but you can use it to set the position anywhere you want. This code uses the jQuery library

            setInterval(function(){
                var dialog = $('.fb_dialog');

                for(var i = 0; i < dialog.length; i++)
                {
                    var d = $(dialog[i]);
                    if(parseInt(d.css('top')) > 0 && parseInt(d.css('top')) != 195)
                    {
                        d.css('top', '195px')
                    }
                }
            }, 500);
like image 39
Pierre Avatar answered Sep 18 '22 21:09

Pierre