# InfiniteScrollModel()
Model for the infinite scroll component. Manages loading states to prevent performance problems like double actions.
# load()
Emits a load event to inform the parent component that it's at the end of a scroll and should load more items.
# shouldCheck()
Informs the caller if this model is in an appropriate state for checking the right (scroll) position.
Returns
boolean
Whether the component should check for the right (scroll) position.
# triggerShouldCheckState()
If the component is not in LOADING state, it should check to see if it should load. This method will be triggered on every scroll event.
# checkShouldLoadMore_()
private method
If in an appropriate state, checks if the scroll position is right and if so triggers a load more event.
# constructor(opt_el)
InfiniteScrollComponent is a small component which checks the scroll position of a given DOM element, and if it's in an appropriate position, fires a LOAD event for the parent component to act upon. When the parent component is done loading new items, it should reset this InfiniteScrollComponent with the reset() method.
Parameters
Name | Types | Description |
---|---|---|
opt_el | !HTMLElement= |
Optional element to track its scroll. |
# dispose()
# e()
# InfiniteScroll()
# onScroll_()
private method
Scroll event handler for infinite scroll. Fires the throttle to check for the correct load more position.
# reset()
# showEndOfList()
# showSpinner()
# template()
# this.EventType()
# this.scrollEl()
# BackButton(opt_config)
Includes back button for back navigation.
Parameters
Name | Types | Description |
---|---|---|
opt_config | NavBar.NavBarOptions= |
Config parameters to include things like title. |
# events()
# NavBar()
# NavBar.NavBarOptions()
# onBackButtonTap()
# onMenuButtonTap()
# template()
# this.config()
# this.vm()
# P2RComponentModel()
Model for the pull to refresh component. Manages refreshing states to prevent performance problems like double actions.
# refresh()
Dispatches a refresh event to inform the parent component that it's at the appropriate position for refresh.
# shouldCheck()
Informs the caller if this model is in an appropriate state for checking the right (scroll) position.
Returns
boolean
Whether the component should check for the right (scroll) position.
# triggerShouldCheckState()
If the component is not in REFRESHING state, it should check to see if it should refresh. This method will be triggered on every scroll event.
# checkShouldRefresh()
If in an appropriate state, checks if the scroll position is right and if so triggers a refresh event.
# constructor(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.
Parameters
Name | Types | Description |
---|---|---|
opt_el | !HTMLElement= |
Optional element to track its scroll. |
# dispose()
# e_()
private method
Fires when the user lifts her finger to finish the scroll. If the user scrolled enough, inform the model to refresh
# mappings()
# onAfterRender()
# onShouldRefresh()
# PullToRefresh()
# PullToRefresh.arrowOffset()
# PullToRefresh.height()
# PullToRefresh.threshold()
# register(scrollEl, containerEl)
Parameters
Name | Types | Description |
---|---|---|
scrollEl | HTMLElement |
Element to track. |
containerEl | HTMLElement= |
Element to offset during activity. |
# reset()
# template()
# this.EventType()
# events()
# EventType()
# mappings()
# Sidebar()
# template()
# this.vm()
# activateItem(index)
Parameters
Name | Types | Description |
---|---|---|
index | number |
Index of the item to be active. |
# deactivateActiveItem()
# events()
# mappings()
# onAfterRender()
# TabView()
# template_views()
# this.activeItemIndex()
# this.views()
# this.vm()
# Component()
# erste()
# erste.use()
# InfiniteScroll()
# locale()
# locale.__()
# NavBar()
# PullToRefresh()
# Sidebar()
# TabView()
# View()
# ViewManager()
# goog()
Base namespace for the Closure library. Checks to see goog is already defined in the current scope before assigning to prevent clobbering if base.js is loaded more than once.
# goog.exportPath_(name, opt_object, opt_objectToExportTo)
private method
Builds an object structure for the provided namespace path, ensuring that names that already exist are not overwritten. For example: "a.b.c" -> a = {};a.b={};a.b.c={}; Used by goog.provide and goog.exportSymbol.
Parameters
Name | Types | Description |
---|---|---|
name | string |
name of the object that this file defines. |
opt_object | *= |
the object to expose at the end of the path. |
opt_objectToExportTo | Object= |
The object to add the path to; default is goog.global . |
# goog.exportProperty(object, publicName, symbol)
Exports a property unobfuscated into the object's namespace. ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction); ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod);
Parameters
Name | Types | Description |
---|---|---|
object | Object |
Object whose static property is being exported. |
publicName | string |
Unobfuscated name to export. |
symbol | * |
Object the name should point to. |
# goog.exportSymbol(publicPath, object, opt_objectToExportTo)
Exposes an unobfuscated global namespace path for the given object. Note that fields of the exported object will be obfuscated, unless they are exported in turn via this function or goog.exportProperty. Also handy for making public items that are defined in anonymous closures. ex. goog.exportSymbol('public.path.Foo', Foo); ex. goog.exportSymbol('public.path.Foo.staticFunction', Foo.staticFunction); public.path.Foo.staticFunction(); ex. goog.exportSymbol('public.path.Foo.prototype.myMethod', Foo.prototype.myMethod); new public.path.Foo().myMethod();
Parameters
Name | Types | Description |
---|---|---|
publicPath | string |
Unobfuscated name to export. |
object | * |
Object the name should point to. |
opt_objectToExportTo | Object= |
The object to add the path to; default is goog.global. |
# goog.isDef(val)
Returns true if the specified value is not undefined.
Parameters
Name | Types | Description |
---|---|---|
val |
|
Variable to test. |
Returns
boolean
Whether variable is defined.
# callHandlers()
Given a list of componentsRegistry, checks whether any component would respond to the given event and if so, executes the event handler defined in the component.
# getComponent(id)
Given an id, returns a component in the registry.
Parameters
Name | Types | Description |
---|---|---|
id | string |
Id for the component instance. |
# markComponentRendered(comp)
Given an id, marks a component as rendered, removing it from the render queue.
Parameters
Name | Types | Description |
---|---|---|
comp | !Component |
Component instance to mark as rendered. |
# removeComponent(comp)
Given an id, removes a component from the registry.
Parameters
Name | Types | Description |
---|---|---|
comp | !Component |
Component instance to remove. |
# setComponent(comp)
Registers a component to the component registry, setting it up for render if it hasn't already been rendered. Also, if this is the first time this type of component is registered, it checks and decomposes the event handler declaration syntax sugar.
Parameters
Name | Types | Description |
---|---|---|
comp | !Component |
Component instance to register. |
# Component()
{@link Component} is a role that determines an aspect of your user interface. It defines what your users see on the page. Every {@link Component} includes a set of behaviors, like what happens when a user clicks on a button. {@link Component}s should be dummy, in that they should have no memory, or state, of their own. {@link Component}s know how to draw a user interface and how to handle user input; whose business logic should be delegated to other classes in the system.
# Component.__events()
# Component.__nonBubblingEvents()
# Component.events()
# constructor(props)
Creates a new {@link View} instance. Users should subclass this class to incorporate their own functionality, as the default View instance doesn't provide anything out of the box.
Parameters
Name | Types | Description |
---|---|---|
props | Object! |
Properties that will be saved as this.props . |
# created(props)
Parameters
Name | Types | Description |
---|---|---|
props | !Object |
The properties passed onto this {@link Component} at instantiation. |
# createdHooks(props)
Parameters
Name | Types | Description |
---|---|---|
props | !Object |
The properties passed onto this {@link Component} at instantiation. |
# dispose()
# onAfterRender()
# onAfterRenderHooks()
# tagExtension_()
Provides template for populating the id
field of a component. Should not be overridden.
# template(props)
Parameters
Name | Types | Description |
---|---|---|
props | !Object |
The properties passed onto this {@link Component} at instantiation. |
Returns
string
# this.props()
# toString()
# ync()
# addListener(emitter, event, fn, context, once)
private method
Add a listener for a given event.
Parameters
Name | Types | Description |
---|---|---|
emitter | EventEmitter |
Reference to the EventEmitter instance. |
event | (string |
Symbol) |
fn | Function |
The listener function. |
context | * |
The context to invoke the listener with. |
once | boolean |
Specify if the listener is a one-time listener. |
# clearEvent(emitter, evt)
private method
Clear event by name.
Parameters
Name | Types | Description |
---|---|---|
emitter | EventEmitter |
Reference to the EventEmitter instance. |
evt | (string |
Symbol |
# EE(fn, context, once)
private method
Representation of a single event listener.
Parameters
Name | Types | Description |
---|---|---|
fn | Function |
The listener function. |
context | * |
The context to invoke the listener with. |
once | boolean |
Specify if the listener is a one-time listener. |
# emit(event, a1, a2, a3, a4, a5)
Calls each of the listeners registered for a given event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
a1 | *= |
|
a2 | *= |
|
a3 | *= |
|
a4 | *= |
|
a5 | *= |
# EventEmitter()
Minimal EventEmitter
interface that is molded against the Node.js EventEmitter
interface.
# Events()
private method
Constructor to create a storage for our EE
objects. An Events
instance is a plain object whose properties are event names.
# listenerCount(event)
Return the number of listeners listening to a given event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
# listeners(event)
Return the listeners registered for a given event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
# on(event, fn, context)
Add a listener for a given event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
fn | Function |
The listener function. |
context | * |
The context to invoke the listener with. |
# once(event, fn, context)
Add a one-time listener for a given event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
fn | Function |
The listener function. |
context | * |
The context to invoke the listener with. |
# removeAllListeners(event)
Remove all listeners, or those of the specified event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
# removeListener(event, fn, context, once)
Remove the listeners of a given event.
Parameters
Name | Types | Description |
---|---|---|
event | (string |
Symbol) |
fn | Function |
Only remove the listeners that match this function. |
context | * |
Only remove the listeners that have this context. |
once | boolean |
Only remove one-time listeners. |
# constructor(opt_el)
Tracks and fires gestures on touch enabled devices.
Parameters
Name | Types | Description |
---|---|---|
opt_el | !HTMLElement= |
Provided, gesture handler will track gesture events on this element. The default value is document.body; but an optional root element is inevitable for iframe's. |
# this.touches()
# this.touchStartTime()
# angle(x1, y1, x2, y2)
Computes the angle between two points (x1,y1) and (x2,y2). Angle zero points in the +X direction, 90 degrees points in the +Y direction (down) and from there we grow clockwise towards 360 degrees.
Parameters
Name | Types | Description |
---|---|---|
x1 | number |
x of first point. |
y1 | number |
y of first point. |
x2 | number |
x of second point. |
y2 | number |
y of second point. |
Returns
number
Standardized angle in degrees of the vector from x1,y1 to x2,y2.
# distance(x1, y1, x2, y2)
Calculates distance between two points given 4 points.
Parameters
Name | Types | Description |
---|---|---|
x1 | number |
X value of the first point |
y1 | number |
Y value of the first point |
x2 | number |
X value of the second point |
y2 | number |
Y value of the second point |
Returns
number
Distance between two points
# lerp(a, b, x)
Performs linear interpolation between values a and b. Returns the value between a and b proportional to x (when x is between 0 and 1. When x is outside this range, the return value is a linear extrapolation).
Parameters
Name | Types | Description |
---|---|---|
a | number |
A number. |
b | number |
A number. |
x | number |
The proportion between a and b. |
Returns
number
The interpolated value between a and b.
# modulo(a, b)
The % operator in JavaScript returns the remainder of a / b, but differs from some other languages in that the result will have the same sign as the dividend. For example, -1 % 8 == -1, whereas in some other languages (such as Python) the result would be 7. This function emulates the more correct modulo behavior, which is useful for certain applications such as calculating an offset index in a circular list.
Parameters
Name | Types | Description |
---|---|---|
a | number |
The dividend. |
b | number |
The divisor. |
Returns
number
a % b where the result is between 0 and b (either 0 <= x < b or b < x <= 0, depending on the sign of b).
# standardAngle(angle)
Normalizes an angle to be in range [0-360). Angles outside this range will be normalized to be the equivalent angle with that range.
Parameters
Name | Types | Description |
---|---|---|
angle | number |
Angle in degrees. |
Returns
number
Standardized angle.
# toDegrees(angleRadians)
Converts radians to degrees.
Parameters
Name | Types | Description |
---|---|---|
angleRadians | number |
Angle in radians. |
Returns
number
Angle in degrees.
# getUid()
Returns a unique identifier string, which is an auto-incremented base-36 counter.
Returns
string
# ErstePlugin()
# function(plugin)
Parameters
Name | Types | Description |
---|---|---|
plugin | ErstePlugin |
An erste plugin to install and use. Its $$register method will be called with erste as the first parameter, allowing it to modify the erste module freely. One common use case is the regie npm library, which is the state management solution for vanilla JavaScript applications and erste. It injects the store into root of erste and allows Components to have a special syntax to declare observations for state properties. |
# __()
# getLocalizedString(text, args)
Return translation of the given text Look for a translation from goog.require()'d scripts. Replace the variables inside the translation. Return the same text if no translation found. Pass in variables as integers inside curly brackets. {0} will be replaced by first argument and so on.
Parameters
Name | Types | Description |
---|---|---|
text | string |
Text to be translated. |
args | ...* |
Translation arguments. |
Returns
string
Localized string.
# setLanguage(lang)
Change the active dictionary
Parameters
Name | Types | Description |
---|---|---|
lang | string |
Language code. |
# default(fn, threshhold, scope)
Parameters
Name | Types | Description |
---|---|---|
fn | !Function |
|
threshhold | number |
|
scope | Object= |
# now()
# backGestureTouchMove_(e)
private method
Handle touch move events when they occur in a back gesture.
Parameters
Name | Types | Description |
---|---|---|
e | !TouchEvent |
Touch end event. |
# closeSidebarTouchMove_(e)
private method
Close sidebar touch move functionality.
Parameters
Name | Types | Description |
---|---|---|
e | !TouchEvent |
# constructor(opt_root)
{@link ViewManager} constructor. At least one {@link ViewManager} should be present in all multi-view erste applications.
Parameters
Name | Types | Description |
---|---|---|
opt_root | (!Element |
!View)= |
# initTouchEvents_()
private method
Initializes touch event handlers for all touch end and touch move events ocurring on the root element.
# onTouchEnd_()
private method
Handles touch end events and decides how the view transitions should follow.
# onTouchMove_()
private method
Handles touch move events and decides how the view transitions should occur.
# pull(view, opt_canGoBack)
Parameters
Name | Types | Description |
---|---|---|
view | !View |
{@link View} instance to pull into the scene. |
opt_canGoBack | boolean= |
Whether the {@link ViewManager} should keep history so that one can go back to the previous {@link View}. Has a hard-coded transition effect similar to iOS7+. |
# push()
# setCurrentView(view, opt_noDispose)
Parameters
Name | Types | Description |
---|---|---|
view | !View |
The view to set as the foremost view. |
opt_noDispose | boolean= |
Whether to dispose the current view. |
# this.currentView()
# this.history()
# this.state_()
private method
Initial state of the viewManager
. Indicates the sidebar is off and there are no active gestures on the root element.
# toggleSidebar()
# ViewManager()
This class handles view transitions and view history in a consistent manner similar to NavigationController
s in other frameworks. An instance of this class should be used by views that will contain other views, and will allow navigation in between them. Also, each multi-view application should have at least one root {@link ViewManager}.
# ViewManager.State()
# ViewManager.topIndex_()
private method
3d transform Z position for the uppermost view. Used to set the right view on top.
# constructor(props)
Creates a new {@link View} instance. Users should subclass this class to incorporate their own functionality, as the default View instance doesn't provide anything out of the box.
Parameters
Name | Types | Description |
---|---|---|
props | !Object |
Properties that will be saved as this.props . |
# document.body(opt_rootEl=document.body, opt_index)
Renders the view into a parent DOM element. The default root element is document.body
, so for the sake of simplicity, one can just call view.render()
to render the view into the DOM.
Parameters
Name | Types | Description |
---|---|---|
opt_rootEl=document.body | HTMLElement= |
Root element to render this view in. |
opt_index | number= |
The index of this view in z-axis. |
# onActivation()
# onAfterRender()
This method is similar to viewDidAppear
or componentDidMount
methods found in other frameworks. It's called automatically when the view is rendered into the DOM. This method already sets thez-index
property and accompanying CSS transforms appropriately, positioning the view to its correct place. Override to provide custom functionality after the view's root element enters the DOM. This can be listening to additional DOM events or manipulating element properties. Make sure to call super.onAfterRender()
when you override this method.
# panIn(isTheViewBeingPulled)
Parameters
Name | Types | Description |
---|---|---|
isTheViewBeingPulled | boolean |
Whether the view is being pull ed or push ed |
# panOut(isTheViewBeingPulled)
Parameters
Name | Types | Description |
---|---|---|
isTheViewBeingPulled | boolean |
Whether the view is being pull ed or push ed. |
# tagExtension_()
Provides template for populating the id
field and adding the view
attribute. Should not be overridden.
# template()
Default template for views. Uses a custom element <view>
, which should be set to display: block
for proper looks.
# View()
The default view class for all the views in an erste application. A {@link View} is simply a {@link Component} with additional convenience features. For example, a {@link View} renders to document.body
by default, whereas a {@link Component} silently ignores the call if no root is provided. Also, regardless of the template, a view
attribute is added to the root DOM elements of each {@link View}, so that uniform styling across all views is possible without much heavy-lifting. For implementing full-screen, navigable views, users should subclass {@link View}. erste requires you to manually instantiate all the views in your application.