Ext.util.Scroller
Hierarchy
Ext.util.ObservableExt.util.DraggableExt.util.ScrollerFiles
Provide the native scrolling experience on iDevices for any DOM element
Available since: 1.1.0
Config options
A higher acceleration gives the scroller more initial velocity. Defaults to 30
Defaults to: 20
Available since: 1.1.0
Enable bouncing during scrolling past the bounds. Defaults to true. (Which is 'both'). You can also specify 'vertical', 'horizontal', or 'both'
Defaults to: true
Available since: 1.1.0
A simple CSS selector that represents elements within the draggable that should NOT initiate a drag.
A simple CSS selector that represents elements within the draggable that should NOT initiate a drag.
Available since: 1.1.0
Inherited
Can be either a DOM element, an instance of Ext.Element, 'parent' or null for no constrain
Defaults to: 'parent'
Available since: 1.1.0
Overrides: Ext.util.Draggable.constrain
How many milliseconds a user must hold the draggable before starting a drag operation. Defaults to 0 or immediate.
Defaults to: 0
Available since: 1.1.0
Inherited
Possible values: 'vertical', 'horizontal', or 'both' Defaults to 'both'
Defaults to: 'both'
Available since: 1.1.0
Overrides: Ext.util.Draggable.direction
Whether or not the draggable behavior is disabled on instantiation Defaults to false
Defaults to: false
Available since: 1.1.0
The element to actually bind touch events to, the only string accepted is 'parent' for convenience. Defaults to this class' element itself
Available since: 1.1.0
The desired fps of the deceleration. Defaults to 70.
Available since: 1.1.0
The friction of the scroller. By raising this value the length that momentum scrolls becomes shorter. This value is best kept between 0 and 1. The default value is 0.5
Defaults to: 0.5
Available since: 1.1.0
Draggable and Droppable objects can participate in a group which are capable of interacting. Defaults to 'base'
Defaults to: 'base'
Available since: 1.1.0
(optional)
A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once.
DOM events from ExtJs Components
While some ExtJs Component classes export selected DOM events (e.g. "click", "mouseover" etc), this
is usually only done when extra value can be added. For example the DataView's
click event passing the node clicked on. To access DOM
events directly from a child element of a Component, we need to specify the element option to
identify the Component property to add a DOM listener to:
new Ext.Panel({
width: 400,
height: 200,
dockedItems: [{
xtype: 'toolbar'
}],
listeners: {
click: {
element: 'el', //bind to the underlying el property on the panel
fn: function(){ console.log('click el'); }
},
dblclick: {
element: 'body', //bind to the underlying body property on the panel
fn: function(){ console.log('dblclick body'); }
}
}
});
Available since: 1.1.0
The minimum velocity to keep animating. Defaults to 1 (1px per second)
Defaults to: 1
Available since: 1.1.0
Whether or not to enable scrolling momentum. Defaults to true
Defaults to: true
Available since: 1.1.0
Determines the offset ratio when the scroller is pulled / pushed out of bound (when it's not decelerating) A value of 0.5 means 1px allowed for every 2px. Defaults to 0.5
Defaults to: 0.5
Available since: 1.1.0
Whether or not the element or it's proxy will be reverted back (with animation) when it's not dropped and held by a Droppable
Defaults to: false
Available since: 1.1.0
The tension of the spring that is attached to the scroller when it bounces. By raising this value the bounce becomes shorter. This value is best kept between 0 and 1. The default value is 0.3
Defaults to: 0.3
Available since: 1.1.0
The time duration in ms to reset the start time of momentum Defaults to 350
Defaults to: 350
Available since: 1.1.0
Whether or not to translate the element using CSS Transform (much faster) instead of left and top properties, defaults to true
Defaults to: true
Available since: 1.1.0
Properties
How long animations for this draggable take by default when using setOffset with animate being true. Defaults to 300.
Defaults to: 300
Available since: 1.1.0
Read-only Property representing whether or not the Draggable is currently dragging or not.
Defaults to: false
Available since: 1.1.0
Defaults to: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|element|vertical|horizontal)$/
Available since: 1.1.0
Read-only value representing whether the Draggable can be moved horizontally. This is automatically calculated by Draggable by the direction configuration.
Defaults to: false
Available since: 1.1.0
Read-only Property representing the region that the Draggable is constrained to.
Read-only Property representing the region that the Draggable is constrained to.
Available since: 1.1.0
The amount of pixels you have to move before the drag operation starts. Defaults to 0
Defaults to: 5
Available since: 1.1.0
Overrides: Ext.util.Draggable.threshold
Whether or not to automatically re-calculate the Scroller's and its container's size on every touchstart. Defaults to true
Defaults to: true
Available since: 1.1.0
Read-only value representing whether the Draggable can be moved vertically. This is automatically calculated by Draggable by the direction configuration.
Defaults to: false
Available since: 1.1.0
Methods
Available since: 1.1.0
Parameters
- el : Mixed
The element you want to make draggable.
- config : Object
The configuration object for this Draggable.
Returns
Overrides: Ext.util.Draggable.constructor
Adds the specified events to the list of events which this Observable may fire.
Available since: 1.1.0
Parameters
- o : Object|String
Either an object with event names as properties with a value of
trueor the first event name string if multiple event names are being passed as separate parameters. - Optional : string
. Event name if multiple event names are being passed as separate parameters. Usage:
this.addEvents('storeloaded', 'storecleared');
Appends an event handler to this object.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to listen for. May also be an object who's property names are event names. See
- handler : Function
The method the event invokes.
- scope : Object (optional)
The scope (
thisreference) in which the handler function is executed. If omitted, defaults to the object which fired the event. - options : Object (optional)
An object containing handler configuration. properties. This may contain any of the following properties:
- scope : ObjectThe scope (
thisreference) in which the handler function is executed. If omitted, defaults to the object which fired the event. - delay : NumberThe number of milliseconds to delay the invocation of the handler after the event fires.
- single : BooleanTrue to add a handler to handle just the next firing of the event, and then remove itself.
- buffer : NumberCauses the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.
- target : ObservableOnly call the handler if the event was fired on the target Observable, not if the event was bubbled up from a child Observable.
- element : StringThis option is only valid for listeners bound to Components. The name of a Component property which references an element to add a listener to.
This option is useful during Component construction to add DOM event listeners to elements of Components which will exist only after the Component is rendered. For example, to add a click listener to a Panel's body:
new Ext.Panel({ title: 'The title', listeners: { click: this.handlePanelClick, element: 'body' } });When added in this way, the options available are the options applicable to Ext.Element.addListener
Combining Options
Using the options argument, it is possible to combine different types of listeners:
A delayed, one-time listener.myPanel.on('hide', this.handleClick, this, { single: true, delay: 100 });Attaching multiple handlers in 1 call
The method also allows for a single argument to be passed which is a config object containing properties which specify multiple events. For example:
.myGridPanel.on({ cellClick: this.onCellClick, mouseover: this.onMouseOver, mouseout: this.onMouseOut, scope: this // Important. Ensure "this" is correct during handler execution }); - scope : Object
Adds listeners to any Observable object (or Element) which are automatically removed when this Component is destroyed.
Available since: 1.1.0
Parameters
- item : Observable|Element
The item to which to add a listener/listeners.
- ename : Object|String
The event name, or an object containing event name properties.
- fn : Function
Optional. If the
enameparameter was an event name, this is the handler function. - scope : Object
Optional. If the
enameparameter was an event name, this is the scope (thisreference) in which the handler function is executed. - opt : Object
Optional. If the
enameparameter was an event name, this is the addListener options.
Removes all listeners for this object including the managed listeners
Available since: 1.1.0
Removes all managed listeners for this object.
Available since: 1.1.0
Inherited docs
Destroys this Draggable instance.
Available since: 1.1.0
Overrides: Ext.util.Draggable.destroy
Enables events fired by this Observable to bubble up an owner hierarchy by calling
this.getBubbleTarget() if present. There is no implementation in the Observable base class.
This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly.
Example:
Ext.override(Ext.form.Field, {
// Add functionality to Field's initComponent to enable the change event to bubble
initComponent : Ext.createSequence(Ext.form.Field.prototype.initComponent, function() {
this.enableBubble('change');
}),
// We know that we want Field's events to bubble directly to the FormPanel.
getBubbleTarget : function() {
if (!this.formPanel) {
this.formPanel = this.findParentByType('form');
}
return this.formPanel;
}
});
var myForm = new Ext.formPanel({
title: 'User Details',
items: [{
...
}],
listeners: {
change: function() {
// Title goes red if form has been modified.
myForm.header.setStyle('color', 'red');
}
}
});
Available since: 1.1.0
Parameters
- events : String/Array
The event name to bubble, or an Array of event names.
Fires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to fire.
- args : Object...
Variable number of parameters are passed to handlers.
Returns
- Boolean
returns false if any of the handlers return false otherwise it returns true.
Get the last actual fps performed by this Scroller. Useful for benchmarking
Available since: 1.1.0
Returns
- Number
The actual fps
Gets the new offset from a touch offset.
Available since: 1.1.0
Parameters
- touchPoint : Ext.util.Offset
The touch offset instance.
Returns the current offset relative to the original location of this Draggable.
Available since: 1.1.0
Returns
- Ext.util.Offset
offset An Ext.util.Offset instance containing the offset.
Returns the element thats is being visually dragged.
Available since: 1.1.0
Returns
- Ext.Element
proxy The proxy element.
Internal method that handles a frame of the offset animation.
Available since: 1.1.0
Checks to see if this object has any listeners for a specified event
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to check for
Returns
- Boolean
True if the event is being listened for, else false
Method to determine whether this Draggable is currently dragging.
Available since: 1.1.0
Returns
- Boolean
Method to determine whether this Draggable can be dragged on the x-axis
Available since: 1.1.0
Returns
- Boolean
Method to determine whether this Draggable can be dragged on the y-axis
Available since: 1.1.0
Returns
- Boolean
Use this to move the draggable to a coordinate on the screen.
Available since: 1.1.0
Parameters
- x : Number
the vertical coordinate in pixels
- y : Number
the horizontal coordinate in pixels
Returns
- Ext.util.Draggable
this This Draggable instance
Appends an event handler to this object (shorthand for addListener.)
Available since: 1.1.0
Parameters
- eventName : String
The type of event to listen for
- handler : Function
The method the event invokes
- scope : Object (optional)
The scope (
thisreference) in which the handler function is executed. If omitted, defaults to the object which fired the event. - options : Object (optional)
An object containing handler configuration.
Fires when a drag events happens. Internal use only.
Available since: 1.1.0
Parameters
- e : Event
The event object for the drag event
Overrides: Ext.util.Draggable.onDrag
Fires when a dragend event happens. Internal use only.
Available since: 1.1.0
Parameters
- e : Event
The event object for the dragend event
Overrides: Ext.util.Draggable.onDragEnd
Inherited docs
Available since: 1.1.0
Parameters
- scroller : Object
- offset : Object
Fires when the orientation changes. Internal use only.
Available since: 1.1.0
Overrides: Ext.util.Draggable.onOrientationChange
Fires when the Drag operation starts. Internal use only.
Available since: 1.1.0
Parameters
- e : Event
The event object for the drag operation
Overrides: Ext.util.Draggable.onStart
Relays selected events from the specified Observable as if the events were fired by this.
Available since: 1.1.0
Parameters
- o : Object
The Observable whose events this object is to relay.
- events : Array
Array of event names to relay.
Removes an event handler.
Available since: 1.1.0
Parameters
- eventName : String
The type of event the handler was associated with.
- handler : Function
The handler to remove. This must be a reference to the function passed into the addListener call.
- scope : Object (optional)
The scope originally specified for the handler.
Removes listeners that were added by the mon method.
Available since: 1.1.0
Parameters
- item : Observable|Element
The item from which to remove a listener/listeners.
- ename : Object|String
The event name, or an object containing event name properties.
- fn : Function
Optional. If the
enameparameter was an event name, this is the handler function. - scope : Object
Optional. If the
enameparameter was an event name, this is the scope (thisreference) in which the handler function is executed.
This method will reset the initial region of the Draggable.
Available since: 1.1.0
Resume firing events. (see suspendEvents) If events were suspended using the queueSuspended parameter, then all events fired during event suspension will be sent to any listeners now.
Available since: 1.1.0
Change the scroll offset by the given amount
Available since: 1.1.0
Parameters
- offset : Ext.util.Offset/Object
The amount to scroll by, e.g {x: 100, y: 200}
- animate : Number/Boolean
Whether or not to animate while changing the scroll position. If it's a number, will be treated as the duration in ms
Returns
- Ext.util.Scroller
this This Scroller
Similar to setOffset, but will stop any existing animation
Available since: 1.1.0
Parameters
- pos : Object
The new scroll position, e.g {x: 100, y: 200}
- animate : Number/Boolean
Whether or not to animate while changing the scroll position. If it's a number, will be treated as the duration in ms
Returns
- Ext.util.Scroller
this This Scroller
Sets the dragging flag and adds a dragging class to the element.
Available since: 1.1.0
Parameters
- dragging : Boolean
True to enable dragging, false to disable.
Returns
Combined method to disable or enable the Draggable. This method is called by the enable and disable methods.
Available since: 1.1.0
Parameters
- enabled : Boolean
True to enable, false to disable. Defaults to false.
Returns
- Ext.util.Draggable
this This Draggable instance
Sets the offset of this Draggable relatively to its original offset.
Available since: 1.1.0
Parameters
- offset : Ext.util.Offset/Object
An object or Ext.util.Offset instance containing the x and y coordinates.
- animate : Boolean/Number
Whether or not to animate the setting of the offset. True to use the default animationDuration, a number to specify the duration for this operation.
Returns
- Ext.util.Draggable
this This Draggable instance
Internal method that sets the left and top of the proxyEl.
Available since: 1.1.0
Parameters
- offset : Ext.util.Offset/Object
An object or Ext.util.Offset instance containing the x and y coordinates.
Returns
- Ext.util.Draggable
this This Draggable instance
Internal method that sets the transform of the proxyEl.
Available since: 1.1.0
Parameters
- offset : Ext.util.Offset/Object
An object or Ext.util.Offset instance containing the x and y coordinates for the transform.
Returns
- Ext.util.Draggable
this This Draggable instance
Change the Draggable to use css transforms instead of style offsets or the other way around.
Available since: 1.1.0
Parameters
- useCssTransform : Boolean
True to use css transforms instead of style offsets.
Returns
- Ext.util.Draggable
this This Draggable instance @public
Snap this scrollable content back to the container's boundary, if it's currently out of bound
Available since: 1.1.0
Parameters
- animate : Object
Returns
- Ext.util.Scroller
this This Scroller
Internal method that sets the offset of the Draggable using an animation
Available since: 1.1.0
Parameters
- offset : Ext.util.Offset/Object
An object or Ext.util.Offset instance containing the x and y coordinates for the transform.
- animate : Boolean/Number
Whether or not to animate the setting of the offset. True to use the default animationDuration, a number to specify the duration for this operation.
Returns
- Ext.util.Draggable
this This Draggable instance
Internal method that stops the current offset animation
Available since: 1.1.0
Returns
Suspend the firing of all events. (see resumeEvents)
Available since: 1.1.0
Parameters
- queueSuspended : Boolean
Pass as true to queue up suspended events to be fired after the resumeEvents call instead of discarding all suspended events;
Removes an event handler (shorthand for removeListener.)
Available since: 1.1.0
Parameters
- eventName : String
The type of event the handler was associated with.
- handler : Function
The handler to remove. This must be a reference to the function passed into the addListener call.
- scope : Object (optional)
The scope originally specified for the handler.
Inherited docs
Updates the boundary information for this Draggable. This method shouldn't have to be called by the developer and is mostly used for internal purposes. Might be useful when creating subclasses of Draggable.
Available since: 1.1.0
Parameters
- init : Boolean
Whether or not this is happing during instantiation, which we need to apply the transform / style to the DOM element
Returns
- Ext.util.Draggable
this This Draggable instance
Overrides: Ext.util.Draggable.updateBoundary
Events
Available since: Touch 1.1.1
Parameters
- this : Ext.util.Scroller
- info : Object
Object containing information regarding the bounce
Available since: 1.1.0
Parameters
- this : Ext.util.Scroller
- info : Object
Object containing information regarding the bounce
Available since: 1.1.0
Parameters
- this : Ext.Draggable
- offset : Ext.util.Offset
Available since: 1.1.0
Parameters
- this : Ext.util.Scroller
- offsets : Object
An object containing the x and y offsets for the scroller.
Available since: 1.1.0
Parameters
- this : Ext.util.Scroller
- offsets : Object
An object containing the x and y offsets for the scroller.