Class: Fx.Scroll

Scrolls any element with an overflow, including the window element.

Note:

Extends:

Fx.Scroll Method: constructor

Синтаксис:

var myFx = new Fx.Scroll(element[, options]);

Аргументы:

  1. element - (mixed) A string of the id for an Element or an Element reference to scroll.
  2. options - (object, optional) All Fx Options in addition to offset, overflown, and wheelStops.

Options:

  1. offset - (object: defaults to {'x': 0, 'y': 0}) An object with x and y properties of the distance to scroll to within the Element.
  2. overflown - (array: defaults to []) An array of nested scrolling containers, see Element:getPosition for an explanation.
  3. wheelStops - (boolean: defaults to true) If false, the mouse wheel will not stop the transition from happening.

Возвращает:

  • (object) A new Fx.Scroll instance.

Примеры:

var myFx = new Fx.Scroll('myElement', {

    offset: {
        'x': 0,
        'y': 100
    }
}).toTop();

Notes:

  • Fx.Scroll transition will stop on mousewheel movement if the wheelStops option is not set to false. This is to allow users to control their web experience.
  • Fx.Scroll is useless for Elements without scrollbars.

Fx.Scroll Method: set

Scrolls the specified Element to the x/y coordinates immediately.

Синтаксис:

myFx.set(x, y);

Аргументы:

  1. x - (integer) The x coordinate to scroll the Element to.
  2. y - (integer) The y coordinate to scroll the Element to.

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

var myElement = $(document.body);
var myFx = new Fx.Scroll(myElement).set(0, 0.5 * document.body.offsetHeight);

Fx.Scroll Method: start

Scrolls the specified Element to the x/y coordinates provided.

Синтаксис:

myFx.start(x, y);

Аргументы:

  1. x - (integer) The x coordinate to scroll the Element to.
  2. y - (integer) The y coordinate to scroll the Element to.

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

var myElement = $(document.body);

var myFx = new Fx.Scroll(myElement).start(0, 0.5 * document.body.offsetHeight);

Notes:

  • Scrolling to negative coordinates is impossible.

Fx.Scroll Method: toTop

Scrolls the specified Element to its maximum top.

Синтаксис:

myFx.toTop();

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

//Scrolls "myElement" 200 pixels down from its top and, after 1.5 seconds,
//back to the top.
var myFx = new Fx.Scroll('myElement', {

    onComplete: function(){
        this.toTop.delay(1500, this);
    }

}).scrollTo(0, 200).chain(function(){

    this.scrollTo(200, 0);
});

Fx.Scroll Method: toBottom

Scrolls the specified Element to its maximum bottom.

Синтаксис:

myFx.toBottom();

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

//Scrolls the window to the bottom and, after one second, to the top.
var myFx = new Fx.Scroll(window).toBottom().chain(function(){

    this.toTop.delay(1000, this);
});

Fx.Scroll Method: toLeft

Scrolls the specified Element to its maximum left.

Синтаксис:

myFx.toLeft();

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

//Scrolls "myElement" 200 pixels to the right and then back.
var myFx = new Fx.Scroll('myElement').scrollTo(200, 0).chain(function(){

    this.toLeft();
});

Fx.Scroll Method: toRight

Scrolls the specified Element to its maximum right.

Синтаксис:

myFx.toRight();

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

//Scrolls "myElement" to the right edge and then to the bottom.
var myFx = new Fx.Scroll('myElement', {

    duration: 5000,
    wait: false
}).toRight();
 
myFx.toBottom.delay(2000, myFx);

Fx.Scroll Method: toElement

Scrolls the specified Element to the position the passed in Element is found.

Синтаксис:

myFx.toElement(el);

Аргументы:

  1. el - (mixed) A string of the Element's id or an Element reference to scroll to.

Возвращает:

  • (object) This Fx.Scroll instance.

Примеры:

//Scrolls the "myElement" to the top left corner of the window.
var myFx = new Fx.Scroll(window).toElement('myElement');

Notes:


Эта документация распостраняется на правах Attribution-NonCommercial-ShareAlike 3.0 License.
Оригинал документации на английском.
© Linux.ria.ua, 2008-2024