Inputs.ScrollInput Class
samsara/inputs/ScrollInput.js:20
Wrapper for DOM wheel/mousewheel events. Converts scroll
events
to start
, update
and end
events and emits them with the payload:
value
- Scroll displacement in pixels from start
delta
- Scroll differential in pixels between subsequent events
velocity
- Velocity of scroll,
clientX
- DOM event clientX property
clientY
- DOM event clientY property
offsetX
- DOM event offsetX property
offsetY
- DOM event offsetY property
Constructor
Inputs.ScrollInput
-
[options]
Parameters:
Example:
var scrollInput = new ScrollInput();
scrollInput.subscribe(Engine) // listens on window
events
scrollInput.on('start', function(payload){
console.log('start', payload);
});
scrollInput.on('update', function(payload){
console.log('update', payload);
});
scrollInput.on('end', function(payload){
console.log('end', payload);
});
Methods
"on"
-
type
-
handler
Adds a handler to the type
channel which will be executed on emit
.
filter
-
filterFn
Parameters:
-
filterFn
FunctionFunction to filter event payload
get
-
key
Look up options value by key or get the full options hash.
Parameters:
-
key
StringKey
Returns:
Associated object or full options hash
getOptions
()
Alias for get
key
-
key
Return OptionsManager based on sub-object retrieved by key
.
Parameters:
-
key
StringKey
Returns:
Value
map
-
mapperFn
Parameters:
-
mapperFn
FunctionFunction to map event payload
off
-
type
-
handler
Removes the handler
from the type
channel.
This undoes the work of on
.
OptionsManager.patch
-
options
-
patch
Constructor method. Create OptionsManager from source dictionary with arguments overriden by patch dictionary.
Parameters:
-
options
ObjectOptions to be patched
-
patch
...ObjectOptions to overwrite
Returns:
source
patch
-
options
Patch options with provided patches. Triggers change
event on the object.
Parameters:
-
options
ObjectPatch options
Returns:
this
pluck
-
key
set
-
key
-
value
Set key to value. Outputs change
event if a value is overwritten.
Returns:
Updated OptionsManager
setOptions
()
Alias for patch
split
-
splitterFn
Parameters:
-
splitterFn
FunctionSplitter function