Index
Methods
Methods
-
<static> UWA.Utils.Scroll.smoothScroll(element, end, options)
-
Animate the scroll of an element
Example
var button = UWA.createElement('button', { type: 'button', text: 'Scroll to top', events: { click: function () { UWA.Utils.Scroll.smoothScroll(scrollableElement, {top: 0}, { onComplete: function () { // Hide the button when we are at the top button.hide(); } }); } } });Parameters
Name Type Description elementElement the scrollable element
endObject scroll destination
Properties
Name Type Description topNumber scroll top destination
leftNumber scroll left destination
optionsObject option hash
Properties
Name Type Description onCompleteFunction callback called when the scroll is finished
-
<static> UWA.Utils.Scroll.scrollToElement(element, options)
-
Scroll until an element is visible
Example
UWA.Utils.Scroll.scrollToElement(element, { smooth: true, onComplete: function () { console.log('Scroll animation complete!'); } });Parameters
Name Type Description elementElement the element to show
optionsObject option hash
Properties
Name Type Argument Default Description topBoolean <optional>
false if the element should be on top even if it is bellow the scrollable zone
bottomBoolean <optional>
false if the element should be at the bottom even if it is on top of the scrollable zone
marginNumber <optional>
0 add a space around the element
scrollableElement <optional>
first overflowing parent the scrollable element to scroll
smoothBoolean <optional>
false be smooth
onCompleteFunction <optional>
callback called when the scroll is finished
-
<static> UWA.Utils.Scroll.preventParentScroll(element, options) → {Function}
-
Prevent the scroll of any element containing the passed element. This is usefull when you want a small zone the user can scroll without scrolling the whole page body.
Example
var scroller = UWA.createElement('div', { styles: { overflow: 'auto' } }); UWA.Utils.Scroll.preventParentScroll(scroller); scroller.inject(parent);Parameters
Name Type Argument Description elementDOMElement the element (scrollable or containing scrollable elements) that should not impact the parent scroll.
optionsObject <optional>
a object containing options
Properties
Name Type Argument Default Description onlyScrollableBoolean <optional>
true by default, the scroll will be prevented only if the scroll occurs in a scrollable element. Set this option to false to prevent scroll on non-scrollable elements.
Returns
to remove the scroll prevention
- Type
- Function