/**
* Provide a simple Flick plugin, which can be used along with the "flick" gesture event, to
* animate the motion of the host node in response to a (mouse or touch) flick gesture.
*
* <p>The current implementation is designed to move the node, relative to the bounds of a parent node and is suitable
* for scroll/carousel type implementations. Future versions will remove that constraint, to allow open ended movement within
* the document.</p>
*
* @module node-flick
*/
PARENT_NODE = "parentNode",
BOUNDING_BOX = "boundingBox",
OFFSET_HEIGHT = "offsetHeight",
OFFSET_WIDTH = "offsetWidth",
SCROLL_HEIGHT = "scrollHeight",
SCROLL_WIDTH = "scrollWidth",
BOUNCE = "bounce",
MIN_DISTANCE = "minDistance",
MIN_VELOCITY = "minVelocity",
BOUNCE_DISTANCE = "bounceDistance",
DECELERATION = "deceleration",
STEP = "step",
DURATION = "duration",
EASING = "easing",
FLICK = "flick",
/**
* A plugin class which can be used to animate the motion of a node, in response to a flick gesture.
*
* @class Flick
* @namespace Plugin
* @param {Object} config The initial attribute values for the plugin
*/
}
/**
* Drag coefficent for inertial scrolling. The closer to 1 this
* value is, the less friction during scrolling.
*
* @attribute deceleration
* @default 0.98
*/
deceleration : {
value: 0.98
},
/**
* Drag coefficient for intertial scrolling at the upper
* and lower boundaries of the scrollview. Set to 0 to
* disable "rubber-banding".
*
* @attribute bounce
* @type Number
* @default 0.7
*/
bounce : {
value: 0.7
},
/**
* The bounce distance in pixels
*
* @attribute bounceDistance
* @type Number
* @default 150
*/
bounceDistance : {
value: 150
},
/**
*
* @attribute minVelocity
* @type Number
* @default 0
*/
minVelocity : {
value: 0
},
/**
* The minimum flick gesture distance (px) for which to trigger the flick response
*
* @attribute minVelocity
* @type Number
* @default 10
*/
minDistance : {
value: 10
},
/**
* The constraining box relative to which the flick animation and bounds should be calculated.
*
* @attribute boundingBox
* @type Node
* @default parentNode
*/
boundingBox : {
valueFn : function() {
}
},
/**
* The constraining box relative to which the flick animation and bounds should be calculated.
*
* @attribute boundingBox
* @type Node
* @default parentNode
*/
step : {
value:10
},
/**
* The custom duration to apply to the flick animation. By default,
* the animation duration is controlled by the deceleration factor.
*
* @attribute duration
* @type Number
* @default null
*/
duration : {
value:null
},
/**
* The custom transition easing to use for the flick animation. If not
* provided defaults to internally to Flick.EASING, or Flick.SNAP_EASING based
* on whether or not we're animating the flick or bounce step.
*
* @attribute easing
* @type String
* @default null
*/
easing : {
value:null
}
};
/**
* The NAME of the Flick class. Used to prefix events generated
* by the plugin.
*
* @property NAME
* @static
* @type String
* @default "pluginFlick"
*/
/**
* The namespace for the plugin. This will be the property on the node, which will
* reference the plugin instance, when it's plugged in.
*
* @property NS
* @static
* @type String
* @default "flick"
*/
/**
* The initializer lifecycle implementation.
*
* @method initializer
* @param {Object} config The user configuration for the plugin
*/
initializer : function(config) {
this._renderClasses();
this.setBounds();
});
},
/**
* based on the boundingBox dimensions.
*
* @method setBounds
*/
setBounds : function () {
if (contentHeight > boxHeight) {
this._minY = 0;
this._scrollY = true;
}
if (contentWidth > boxWidth) {
this._minX = 0;
this._scrollX = true;
}
},
/**
* node and boundingBox.
*
* @method _renderClasses
* @protected
*/
_renderClasses : function() {
},
/**
* The flick event listener. Kicks off the flick animation.
*
* @method _onFlick
* @param e {EventFacade} The flick event facade, containing e.flick.distance, e.flick.velocity etc.
* @protected
*/
_onFlick: function(e) {
this._flick = true;
this._flickAnim();
},
/**
* Executes a single frame in the flick animation
*
* @method _flickFrame
* @protected
*/
_flickAnim: function() {
var y = this._y,
x = this._x,
this._snapToEdge = false;
if (this._scrollX) {
}
if (this._scrollY) {
}
this._flick = false;
if (this._scrollX) {
if (x < minX) {
this._snapToEdge = true;
} else if (x > maxX) {
this._snapToEdge = true;
}
}
if (this._scrollY) {
if (y < minY) {
this._snapToEdge = true;
} else if (y > maxY) {
this._snapToEdge = true;
}
}
} else {
this._exceededXBoundary = true;
}
this._exceededYBoundary = true;
}
if (this._scrollX) {
this._setX(x);
}
if (this._scrollY) {
this._setY(y);
}
}
},
/**
* Internal utility method to set the X offset position
*
* @method _setX
* @param {Number} val
* @private
*/
},
/**
* Internal utility method to set the Y offset position
*
* @method _setY
* @param {Number} val
* @private
*/
},
/**
* Internal utility method to move the node to a given XY position,
* using transitions, if specified.
*
* @method _move
* @param {Number} x The X offset position
* @param {Number} y The Y offset position
* @param {Number} duration The duration to use for the transition animation
* @param {String} easing The easing to use for the transition animation.
*
* @private
*/
if (x !== null) {
x = this._bounce(x);
} else {
x = this._x;
}
if (y !== null) {
y = this._bounce(y);
} else {
y = this._y;
}
this._x = x;
this._y = y;
},
/**
* Internal utility method to perform the transition step
*
* @method _anim
* @param {Number} x The X offset position
* @param {Number} y The Y offset position
* @param {Number} duration The duration to use for the transition animation
* @param {String} easing The easing to use for the transition animation.
*
* @private
*/
var xn = x * -1,
yn = y * -1,
transition = {
};
if (Y.Transition.useNative) {
} else {
}
},
/**
* Internal utility method to constrain the offset value
* based on the bounce criteria.
*
* @method _bounce
* @param {Number} x The offset value to constrain.
* @param {Number} max The max offset value.
*
* @private
*/
if(!bounce) {
}
}
return val;
},
/**
* Stop the animation timer
*
* @method _killTimer
* @private
*/
_killTimer: function() {
if(this._flickTimer) {
this._flickTimer.cancel();
}
}
}, {
/**
* The threshold used to determine when the decelerated velocity of the node
* is practically 0.
*
* @property VELOCITY_THRESHOLD
* @static
* @type Number
* @default 0.015
*/
VELOCITY_THRESHOLD : 0.015,
/**
* The duration to use for the bounce snap-back transition
*
* @property SNAP_DURATION
* @static
* @type Number
* @default 400
*/
SNAP_DURATION : 400,
/**
* The default easing to use for the main flick movement transition
*
* @property EASING
* @static
* @type String
* @default 'cubic-bezier(0, 0.1, 0, 1.0)'
*/
EASING : 'cubic-bezier(0, 0.1, 0, 1.0)',
/**
* The default easing to use for the bounce snap-back transition
*
* @property SNAP_EASING
* @static
* @type String
* @default 'ease-out'
*/
SNAP_EASING : 'ease-out',
/**
* The default CSS class names used by the plugin
*
* @property CLASS_NAMES
* @static
* @type Object
*/
CLASS_NAMES : {
}
});