#17 new
Kay Heunen

Element.scrollTo

Reported by Kay Heunen | August 19th, 2010 @ 03:23 PM

In addition to ticket #9. The Scripty2 documentation tells us that there is a possibility to add options to the effect.
So you can add options, but than Scripty2 doesn't do anything with them.

So I'd really like to add this ticket as a Todo, so you can add options like duration, so the scrolling goes smooth. Now it's just the same as prototype's scrollTo().

Comments and changes to this ticket

  • Kay Heunen

    Kay Heunen August 20th, 2010 @ 03:13 AM

    • Assigned user set to “ronin-15560 (at lighthouseapp)”
  • Filippo Buratti

    Filippo Buratti October 27th, 2010 @ 02:45 PM

    Meanwhile, two alternatives for a smooth scroll:

    var docScrollTop = document.viewport.getScrollOffsets().top;
    var itemOffsetTop = $(itemID).cumulativeOffset().top;
    
    new S2.FX.Attribute(
        window,
        docScrollTop,
        itemOffsetTop, 
        { duration: 0.5 },  
        function(l){ 
        window.scrollTo(0,l.round());
        }
    ).play();
    

    or (thanks to R. Stankov, also works for a horizontal scroll):

    S2.FX.scrollSP = Class.create(S2.FX.Base, {
        
        initialize: function($super, element, options){
            if(!(this.element = $(element))) throw(S2.FX.elementDoesNotExistError);
    
            $super(options);
            this.play();
        },
    
        setup: function(){
            var scroll = document.viewport.getScrollOffsets(),
            offset = this.element.cumulativeOffset();
        
            this.startLeft = scroll.left;
            this.startTop = scroll.top;
            this.left = offset.left - this.startLeft;
            this.top = offset.top - this.startTop;
        },
    
        update: function(position){
            position = this.options.transition(position);
            scrollTo(this.startLeft + this.left * position, this.startTop + this.top * position);
        }
        
    });
    

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

http://github.com/madrobby/scripty2

People watching this ticket

Pages