Categories

.scrollTo()

Categories: UI

.scrollTo( target, [ duration ], [ options ] )Returns: jQuery

Plugin: jQuery.fn.scrollTo

Description: Scroll content of each element in the set of matched elements.

  • .scrollTo( target, [ duration ], [ options ] )

    version added: 1.0

    target   A specified target position.

    duration   A number determining how long the animation will run.

    options   A map of additional options pass to the method.

Animated scrolling for scrolling elements, or the window itself.

There are many different ways to specify the target position:

  • A raw number
  • A string('44', '100px', '+=30px', etc )
  • A DOM element (logically, child of the scrollable element)
  • A selector, that will be relative to the scrollable element
  • The string 'max' to scroll to the end.
  • A string specifying a percentage to scroll to that part of the container (f.e: 50% goes to to the middle).
  • A hash { top:x, left:y }, x and y can be any kind of number/string like above.

Thanks for this great plugin to Ariel Flesler.

  • Scroll content of a pane div.

    Code:
    $('div.pane').scrollTo({ top:150, left:50 });
  • axis

    version added: 1.0

    Axes to be scrolled, 'x', 'y', 'xy' or 'yx'.

    Default: 'xy'

  • duration

    version added: 1.0

    A string or number determining how long the animation will run.

    Default: 'normal'

  • easing

    version added: 1.0

    Name of the easing equation.

  • margin

    version added: 1.0

    If true, target's border and margin are deducted.

    Default: false

  • offset

    version added: 1.0

    Number or hash {left: x, top:y }. This will be added to the final position(can be negative).

  • over

    version added: 1.0

    Add a fraction of the element's height/width (can also be negative).

  • queue

    version added: 1.0

    If true and both axes are scrolled, it will animate on one axis, and then on the other. Note that 'axis' being 'xy' or 'yx', concludes the order.

    Default: false

  • onAfterFirst

    version added: 1.0

    If queing, a function to be called after scrolling the first axis.

  • onAfter

    version added: 1.0

    A function to be called after the whole animation ended.