new tart.ui.P2RComponent(opt_el)
P2RComponent is a small component which checks the scroll position of a given DOM element, and if it's in an appropriate position, fires a REFRESH event for the parent component to act upon. When the parent component is done with refreshing, it should reset this P2RComponent with the reset() method.
Name | Type | Description |
---|---|---|
opt_el |
Element |
optional
Optional element to track its scroll. |
Extends
Members
-
arrowOffsetnumber
-
Start position of the arrow. This is adjusted for a spring-like effect.
-
heightnumber
-
Height of this component. This setting is used to offset the scroll view while refreshing.
-
mappingsstring
-
Properties:
Name Type Default Description ARROW
string .pull-to-refresh-arrow SPINNER
string .pull-to-refresh-spinner -
thresholdnumber
-
Threshold value for the release action. Releases after this threshold will trigger a refresh.
Methods
-
inherited protectedbindModelEvents()
-
Listens to the model's events. This method should be overriden by the implementer, and should keep the model's event listeners.
-
checkShouldRefresh(e)
-
If in an appropriate state, checks if the scroll position is right and if so triggers a refresh event.
Name Type Description e
goog.events.BrowserEvent Scroll event object.
-
inherited disposeInternal()
-
-
inherited getChild(selector){Object}
-
Returns children of component's element
Name Type Description selector
string Expression which is searching in component element. This is kind of $ for selecting dom element.
Returns:
Type Description Object -
inherited getElement(){Element}
-
Returns the dom element attached with the Component instance.
Returns:
Type Description Element -
inherited getId(){string}
-
Returns the id of this component.
Returns:
Type Description string The id of this component. -
inherited getPlaceholder(){string}
-
Returns base template of component
Returns:
Type Description string -
onScroll(e)
-
Scroll event handler for pull to refresh.
Name Type Description e
goog.events.BrowserEvent Scroll event object.
-
onShouldRefresh()
-
Triggered when the components decides a refresh action. This method should be overridden to, for example, display a spinner animation during refresh.
-
register(el)
-
Registers an element to track its scroll. This can be used for lazily introducing an element to track.
Name Type Description el
Node Element to track.
-
inherited render(opt_base, opt_index)
-
This method should be called after the DlgComponent is inserted into the document. Any work (rendering child components, updating DOM, etc.) should be done in this method.
Name Type Description opt_base
Element optional Optional element to render this item into.
opt_index
number optional Place to render element in base element's children list.
-
reset()
-
Resets the component state to default. This should be used to signal the end of refreshing so that this component can again check for pull to refresh.
-
inherited templates_base(){string}
-
Template of the root element. This method can be overridden if necessary. Other templates should be named with the templates_ prefix as necessary. Also this template carries related component's id.
Returns:
Type Description string