great! I didn't think of adding options to the existing function.

thks.


On Mar 23, 4:32 am, kangax <[EMAIL PROTECTED]> wrote:
> What about:
>
> scrollTo: function(element, options) {
>   element = $(element);
>   Object.extend({ x: true, y: true }, options || { });
>   var pos = this.cumulativeOffset(element);
>   window.scrollTo(
>     options.x ? pos[0] : window.scrollX,
>     options.y ? pos[1] : window.scrollY
>   );
>   return element;
>
> }
>
> $(element).scrollTo({x: false}); // scrolls by y only
> $(element).scrollTo({y: false}); // scrolls by x only
>
> - kangax
>
> On Mar 22, 5:00 am, tbela99 <[EMAIL PROTECTED]> wrote:
>
> > Hello guys,
>
> > I found your function Element.scrollTo() very usefull, but it scrolls
> > the till the element gets in the left top corner of the window but
> > sometimes this is not really what we want.
>
> > so I propose these two methods that all to scroll only to the X or the
> > Y axis
>
> > //old one
> > scrollTo: function(element) {
> >                                     element = $(element);
> >                                     var pos = 
> > this.cumulativeOffset(element);
> >                                     window.scrollTo(pos[0], pos[1]);
> >                                     return element;
> >                                 },
>
> > scrollX: function(element) {
> >                                     element = $(element);
> >                                     var pos = 
> > this.cumulativeOffset(element);
> >                                     window.scrollTo(pos[0], window.scrollY);
> >                                     return element;
> >                                 },
> > scrollY: function(element) {
> >                                     element = $(element);
> >                                     var pos = 
> > this.cumulativeOffset(element);
> >                                     window.scrollTo(window.scrollX, pos[1]);
> >                                     return element;
> >                                 }
>
> > regards.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to