core/scroll_manager

Scroll manager is a class that help with saving the scroll positing when you click on an action icon, and then when the page is reloaded after processing the action, it scrolls you to exactly where you were. This is much nicer for the user.

To use this in your code, you need to ensure that:

  1. The button that triggers the action has to have a click event handler that calls saveScrollPos()
  2. After doing the processing, the redirect() function will add 'mdlscrollto' parameter into the redirect url automatically.
  3. Finally, on the page that is reloaded (which should be the same as the one the user started on) you need to call scrollToSavedPosition() on page load.
Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Members

(static, constant) initLinksScrollPos

Source:

Init event handlers for all links with data-save-scroll=true. Handle to add mdlscrollto parameter to link using js when we click on the link.

(static, constant) saveScrollPos

Source:

In the form that contains the element, set the value of the form field with name mdlscrollto to the current scroll position. If there is no element with that name, it creates a hidden form field with that name within the form.

(static, constant) saveScrollPositionToForm

Source:

Save the position to form.

(static, constant) scrollToSavedPosition

Source:

If there is a parameter like mdlscrollto=123 in the URL, scroll to that saved position.

(static, constant) watchScrollButtonSaves

Source:

Init event handlers for all links with data-savescrollposition=true. Set the value to the closest form.

(inner) scrollingElement

Source:
Properties:
Name Type Description
scrollingElement HTMLElement

the current scrolling element.

Methods

(inner) getScrollingElement() → {HTMLElement}

Source:

Get the scrolling element.

Returns:
Type
HTMLElement

(inner) getScrollPos() → {Number}

Source:

Get current scroll position.

Returns:

Scroll position.

Type
Number

(inner) getScrollPositionElement(form) → {HTMLInputElement}

Source:

Get the scroll position for this form.

Parameters:
Name Type Description
form HTMLFormElement
Returns:
Type
HTMLInputElement

(inner) isScrollable(element) → {boolean}

Source:

Is the element scrollable?

Parameters:
Name Type Description
element HTMLElement

Element.

Returns:
Type
boolean