- core
- Context
- ElementAllocator
- ElementOutput
- Engine
- Entity
- EventEmitter
- EventHandler
- Group
- Modifier
- OptionsManager
- RenderNode
- Scene
- SpecParser
- Transform
- View
- ViewSequence
- events
- EventArbiter
- EventFilter
- EventMapper
- inputs
- Accumulator
- GenericSync
- MouseSync
- PinchSync
- RotateSync
- ScaleSync
- ScrollSync
- TouchSync
- TouchTracker
- TwoFingerSync
- math
- Matrix
- Quaternion
- Random
- Utilities
- Vector
- modifiers
- Draggable
- Fader
- ModifierChain
- StateModifier
- physics
- PhysicsEngine
- physics/bodies
- Body
- Circle
- Particle
- Rectangle
- physics/constraints
- Surface
- Collision
- Constraint
- Curve
- Distance
- Snap
- Wall
- Walls
- physics/forces
- Drag
- Force
- Repulsion
- RotationalDrag
- RotationalSpring
- Spring
- VectorField
- physics/integrators
- SymplecticEuler
- surfaces
- CanvasSurface
- ContainerSurface
- ImageSurface
- InputSurface
- TextareaSurface
- VideoSurface
- transitions
- CachedMap
- Easing
- MultipleTransition
- SnapTransition
- SpringTransition
- Transitionable
- TransitionableTransform
- TweenTransition
- WallTransition
- utilities
- KeyCodes
- Timer
- Utility
- views
- ContextualView
- Deck
- DrawerLayout
- EdgeSwapper
- FlexibleLayout
- Flipper
- GridLayout
- HeaderFooterLayout
- Lightbox
- RenderController
- ScrollContainer
- Scroller
- Scrollview
- SequentialLayout
- widgets
- NavigationBar
- TabBar
MouseSync
Handles piped in mouse drag events. Outputs an object with the position delta from last frame, position from start, current velocity averaged out over the velocitySampleLength (set via options), clientX, clientY, offsetX, and offsetY. Emits 'start', 'update' and 'end' events. Designed to be used either as a standalone MouseSync, or as part of a GenericSync.
Overview
Options
clickThreshold
direction
rails
velocitySampleLength
propogate
Methods
getOptions
setOptions
MouseSync(options)
Constructor Parameters
options
Object
An object of the following configurable options.
clickThreshold
Number
Absolute distance from click origin that will still trigger a click.
direction
Number
Read from a particular axis. Valid options are: undefined, 0 or 1. 0 corresponds to x, and 1 to y. Default is undefined, which allows both x and y.
rails
Boolean
Read from axis with the greatest differential.
velocitySampleLength
Number
Number of previous frames to check velocity against.
propogate
Boolean
Add a listener to document on mouseleave. This allows drag events to continue across the entire page.
Methods
_handleStart()Private
Triggered by mousedown.
_handleMove()Private
Triggered by mousemove.
_handleEnd()Private
Triggered by mouseup on the element or document body if propagation is enabled, or mouseleave if propagation is off.
_handleLeave()Private
Switches the mousemove listener to the document body, if propagation is enabled.
getOptions()
Return entire options dictionary, including defaults.
Returns
Object
configuration options
setOptions(options)
Set internal options, overriding any default options
Parameters
options
Object
default options overrides
Example
var Surface = require('../core/Surface');
var MouseSync = require('../inputs/MouseSync');
var surface = new Surface({ size: [100, 100] });
var mouseSync = new MouseSync();
surface.pipe(mouseSync);
mouseSync.on('start', function (e) { // react to start });
mouseSync.on('update', function (e) { // react to update });
mouseSync.on('end', function (e) { // react to end });