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