JavaScript

A5.u.elementsetScroll Method

Syntax

A5.u.element.setScroll(element,x,y[,scrollAbsSettings])

A5.u.element.setScroll(element,childElement[,scrollToSettings])

Arguments

elementelementstring

A pointer to a DOM element or the ID of an element.

xnumber

The X location in pixels to scroll.

ynumber

The Y location in pixels to scroll.

childElementelementstring

A pointer to a child DOM element or the ID of an child element to scroll to.

scrollAbsSettingsobject

Scroll setting for an absolute (X/Y) scroll.

fireEventboolean

Set to true to fire the native scroll event once the scrolling has been set. The default is false.

axisstring

What axes to scroll on. Values can be "both", "x" or "y".

animationobject

If the A5 frameworks custom scrolling is being used, whether to preform the scroll with an animation from the current location to the new location.

allowboolean

Set to true to allow the animation. The default is false.

durationnumber

The duration (in milliseconds) the that the animation should take.

scrollToSettingsobject

Scroll setting for a scroll to child element scroll.

modestring

How the child element should be scrolled to. The default value is "into-view", which will scroll the child element into view with the least amount of scrolling (child element aligned to the nearest edge). A value of "top" will scroll the element so that it is at the top of the scrollable area. A value of "bottom" will scroll the element so that it is at the bottom of the scrollable area.

viewobject

Optional edge scrolling settings for when the target element overflows the scrollable area.

xstring

The horizontal edge to scroll to when the target element is wider then the scrollable area. Values can be "left" (the default), "right" or "nearest". A value of "none" will not scroll the "x" axis if any of the target element is visible.

ystring

The vertical edge to scroll to when the target element is wider then the scrollable area. Values can be "top" (the default), "bottom" or "nearest". A value of "none" will not scroll the "y" axis if any of the target element is visible.

offsetobject

Optional offset for the scrolling.

xnumber

The number of pixels extra to add to the X axis. For example, a value of 10 will mean that the element will be scrolled so that it is 10 pixels away from the edge of the scrollable area.

ynumber

The number of pixels extra to add to the Y axis. For example, a value of 10 will mean that the element will be scrolled so that it is 10 pixels away from the edge of the scrollable area.

fireEventboolean

Set to true to fire the native scroll event once the scrolling has been set. The default is false.

axisstring

What axes to scroll on. Values can be "both", "x" or "y".

animationobject

If the A5 frameworks custom scrolling is being used, whether to preform the scroll with an animation from the current location to the new location.

allowboolean

Set to true to allow the animation. The default is false.

durationnumber

The duration (in milliseconds) the that the animation should take.

Description

Sets the scroll position of the passed in element.

Discussion

A5.u.element.setScroll can be used to set the scroll position of an element whether the element is using the A5 frameworks custom scrolling (drag scrolling for mobile), or the browser native scrolling. The absolute X/Y location can be passed in, or a child element to scroll to.

Example

// assume "id" is the ID of a panel body
A5.u.element.setScroll(id,0,200);
// assume "childEle" is a child element in the panel body
A5.u.element.setScroll(id,childEle,{
	mode: 'top', // scroll element to top
	axis: 'y', // restrict to vertical scrolling
	offset: {
		y: 10 // move element away from edge
	},
	animation: {allow: true} // preform scroll with animation
});