Hi again. Really glad you like the code and the site. :-)

Feel free to ask me JS related stuff any time. You'll usually have better success posting questions to the list, though, because there are a lot of people here smarter and more experienced than I am. But, I'd be glad help in any way that I can.

--Karl


On Oct 30, 2007, at 4:24 PM, jmancor wrote:


That was precisely accurated!  its exactly what i was looking for!....
impressive huh!
Thanks so much... i really like the way u code without making too many
functions.
I was surfing around  www.learningjquery.com really nice mate!
Thanks again and one more question.. can i bother you again to ask you
some JS related stuff?
Best regards,

Jmc.

On Oct 30, 2:13 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
Hey, no problem at all. It was fun.

I think you're mistaken about where the preloader will show up.

Take a look at the demo page I put together:

http://test.learningjquery.com/center.html

click on a "center" button, and see where the div goes. scroll down
and click on another button. the div still goes to the center of the
viewable area. At least, it does for me. :-)

--Karl
_________________
Karl Swedbergwww.englishrules.comwww.learningjquery.com

On Oct 30, 2007, at 12:01 PM, jmancor wrote:



Hey Karl Thank yo so much for this.. it works perfectly but... i made
a mistake.  What im trying to achieve is to show the preloader
wherever my scroll is. I mean.. let's suppose i got a huge scroll and
im in the lower middle of if but i trigger an event and i want my
preloader to show up. Right now the preloader would show up on the
very middle of the whole page wich i wont be able to see if my focus
is on the lower middle got the idea? i wanna make it showable wherever
my focus is!
It has something to do with the portion of screen im watching through
my display!  i'm not sure if you got me! but hey.. this code is
amazing!... thank you so much ofr the help!! without it i would be
lost!
If you can help me out one more time.. i would really appreciate it!

Thanks in advance and best regards!

Jmc.

On Oct 29, 10:22 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
On Oct 29, 2007, at 7:36 PM, jmancor wrote:

Hello everyone!
I got this question going around my head and its just because i
can't
find a proper solution.
Thing is i got a project on which i want to show a preloader
whenever
something is sent or some event has been triggered. How could i set
the preloader to show itself right on the middle of the screen??
I mean how could i show it on the right middle of the screen even if
got a huge scrollbar on the right side!?
I know i should be using <div>'s for every thing i want to show like
this preloader for example but i could perform this with
prototype....errmmmm don't want to use it anymore... cuz we got
Jquery!!!
So any hints???

Thanks in advance!!

Jmancor.

Hi there,

I grabbed some stuff from the Dimensions plugin because the latest
(non-svn) jQuery build incorrectly shows $(window).height() to be the
same as $(document).height(). So here is one way you could get
vertical centering in the viewport (only tested in FF 2 Mac) ...

// vertically center something in the viewport

(function($){
   $.fn.vCenter = function(options) {
     var pos = {
       sTop : function() {
         return window.pageYOffset || $.boxModel &&
document.documentElement.scrollTop ||   document.body.scrollTop;
       },
       wHeight : function() {
         if ( $.browser.opera || ($.browser.safari && parseInt
($.browser.version) > 520) ) {
                        return window.innerHeight - (($
(document).height() >
window.innerHeight) ? getScrollbarWidth() : 0);
                } else if ( $.browser.safari ) {
                        return window.innerHeight;
                }       else {
return $.boxModel && document.documentElement.clientHeight
|| document.body.clientHeight;
         }
       }
     };
     return this.each(function(index) {
       if (index == 0) {
         var $this = $(this);
         var elHeight = $this.height();
         $this.css({
           position: 'absolute',
           marginTop: '0',
           top: pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2)
         });
       }
     });
   };

})(jQuery);

// center an element

$(document).ready(function() {
   $('#foo').vCenter();

});

--Karl
_________________
Karl Swedbergwww.englishrules.comwww.learningjquery.com


Reply via email to