Class: Scroller

The Scroller is a Class to scroll any element with an overflow (including the window) when the mouse cursor reaches certain boundaries of that element.

You must call its start method to start listening to mouse movements.

Примітка:

Синтаксис:

new Scroller(element[, options]);

Реалізує:

Events, Options

Аргументи:

  1. element - (element) The element to scroll.
  2. options - (object, optional) An object for the Scroller instance's options.

Опції:

  • area - (number: defaults to 20) The necessary boundaries to make the element scroll.
  • velocity - (number: defaults to 1) The modifier for the window scrolling speed.

Події:

  • change - (function) When the mouse reaches some boundaries, you can choose to alter some other values, замість of the scrolling offsets.

Підпис:

onChange(x, y);

Аргументи:

  1. x - (number) Current x-mouse position.
  2. y - (number) Current y-mouse position.

Приклади:

var myScroller = new Scroller(window, {
    area: Math.round(window.getWidth() / 5)

});
 
(function(){
    this.stop();
    this.start();

}).periodical(1000, myScroller);

Scroller Method: start

The scroller starts listening to mouse movements.

Синтаксис:

myScroller.start();

Приклади:

var myScroller = new Scroller('myElement');
myScroller.start();

Scroller Method: stop

The scroller stops listening to mouse movements.

Синтаксис:

myScroller.start();

Приклади:

var myElement = $('myElement');
var myScroller = new Scroller(myElement);
myScroller.start();

 
myElement.addEvent('click', myScroller.stop.bind(myScroller)); //stop scrolling when the user clicks.

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