You are reading 12.6.4. See this page in 13.4.1.
Titanium.UI.iOS.SnapBehavior
Extends Titanium.Proxy
Dynamic behavior defining an item's movement to a specific point.
A snap behavior specifies how an item moves towards a specified point with a spring-like effect, ending with an oscillation.
- Use the Titanium.UI.iOS.createSnapBehavior method to create the behavior.
- Set the item and snapPoint properties.
- Add the behavior to an Animator object.
Examples
Simple Example
The following example snaps the block to the location of a click on the window.
var win = Ti.UI.createWindow({backgroundColor: 'white', fullscreen: true});
// Create an Animator object using the window as the coordinate system
var animator = Ti.UI.iOS.createAnimator({referenceView: win});
var block = Ti.UI.createView({
width: 100,
height: 100,
backgroundColor: 'blue'
});
// Snap to the top-left corner when the app starts
var snap = Ti.UI.iOS.createSnapBehavior({
item: block,
snapPoint: {x: 0, y: 0},
});
animator.addBehavior(snap);
// Snap the block to the point of the click event
win.addEventListener('click', function(e){
snap.snapPoint = {x: e.x, y: e.y};
snap.damping = Math.random();
});
// Start the animation when the window opens
win.addEventListener('open', function(e){
animator.startAnimator();
});
win.add(block);
win.open();
Properties 5
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
damping
NumberSpecifies the amount of oscillation during the conclusion of the snap.
A value of 0.0 indicates minimum oscillation, while 1.0 indicates maximum oscillation.
Default: 0.5
Item to add to this behavior.
Specifies the point to snap to.
The coordinate system depends on the animator's reference view.
Default: (0,0)
Methods 4
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|