ScrollEventArgs Constructor

Syntax

ScrollEventArgs(deltaMove: Number, coef: Number);

Parameters

deltaMove. Slider current position in the scrollbar.

coef. Total length of the scrollbar.

Description

The ScrollEventArgs method creates an instance of the ScrollEventArgs class.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create a scrollbar, move it slider by 50 pixels, process the slider move event ScrollBar.MoveScroll:

// Create a scrollbar
var scrollBar = new PP.Ui.ScrollBar({
    ParentNode: document.body,
    Width: 200,
    Height: 16
});
// Process the MoveScroll event
scrollBar.MoveScroll.add(function (sender, args) {
    console.log("Scroll percentage: " + args.DeltaMove / args.Coef * 100);
});
// Scroll the counter by 50 pixels
var value = 50;
scrollBar._dragger.style.left = value + "px";
// Determine parameters for the MoveScroll event
var scrollEventArgs = new PP.ScrollEventArgs(0, 0);
scrollEventArgs.DeltaMove = value; // Scroll value
scrollEventArgs.Coef = scrollBar._limit; // Total length of scrollbar
// Fire the MoveScroll event
scrollBar.MoveScroll.fire(scrollBar.getDomNode(), scrollEventArgs);

After executing the example a scrollbar is created and its slider is moved by 50 pixels:

After firing the ScrollBar.MoveScroll event the browser console displays scroll percentage for this slider:

Scroll percentage: 32.6797385620915

See also:

ScrollEventArgs