hlStickyStack
Service to keep track of a multiple sticky element in a row.
var stickyStackInstance = hlStickyStack(options:object); stickyStackInstance.add(id:int, values:object); stickyStackInstance.remove(id:int,string); stickyStackInstance.removeTop(id:int,string); stickyStackInstance.get(id:int,string); stickyStackInstance.top(); stickyStackInstance.index(id:int,string); stickyStackInstance.range(start:int, end:int); stickyStackInstance.all(); stickyStackInstance.length(); stickyStackInstance.keys(); stickyStackInstance.height(anchor:string); stickyStackInstance.heightCurrent(anchor:string); stickyStackInstance.heightAt(anchor:string, at:int);
hlStickyStack(options:object)
options
name
(Default: 'default-stack') - The name of the stack.
The name of a stack is unique. So if you supply a name, you either create a new stack or return an existing one.
Once you have an instance a few methods are made available to you.
add(id:string, values:object)
Adds a sticky element to the stack.
Returns the compiled values
object.
id
Id of the sticky element you want to add.
If it's not a string the id will become the index from the latest position it will be added to in the stack.
values
Simple object which sticky element information.
remove(id:string|int)
Removes a sticky element from the stack.
Returns the removed item object.
id
Id of the sticky element you want to remove.
removeTop(id:string|int)
Removes a latest added sticky element from the stack.
Returns the removed item object.
id
Id of the sticky element you want to remove.
get(id:string|int)
Gets a sticky element from the stack based on an id.
Returns the requested object.
id
Id of the sticky element you want to get.
top()
Get the latest added sticky element from the stack.
Returns the latest added sticky element object.
index(id:string|int)
Gets the index from a sticky element it has in the stack.
Returns the requested sticky element index.
id
Id of the sticky element you want to get the index from.
range(id:string|int)
Gets a range of sticky elements from the stack based on a begin and end index.
Returns the requested sticky element objects in an array.
start
Start index
end
End index
all()
Gets all the sticky elements from a the stack.
Returns all the sticky element object in an array (It's the raw object, so it's not a copy. Use it wisely).
length()
Get the amount of sticky elements from the stack.
Returns integer indicating the total amount of sticky elements.
keys()
Gets all the sticky element ids from the stack.
Returns all the sticky element ids in an array in the order they have been added.
height(anchor:string)
Calculates the height of all the sticky elements in the stack regardless if they are sticky or not.
anchor
Filter only on a certain anchor position.
Read more about anchors.
heightCurrent(anchor:string)
Calculates the height of all the sticky elements in the stack that are sticky when the method is called.
anchor
Filter only on a certain anchor position.
Read more about anchors.
heightAt(anchor:string, at:int)
Calculates the height of all the sticky elements in the stack that would be sticky at a certain scroll position in pixels.
anchor
Filter only on a certain anchor position.
Read more about anchors.
at
Number of scrolled pixels