Permalink
Browse files

Added scrollViewWillScroll delegate method to coherent.ScrollView. Th…

…is currently has some issues, because pageX & pageY will have the new position while x & y will have the old position.
  • Loading branch information...
1 parent 6322427 commit 2993dbc52bb86e00b100359a20922b4e61eff22f @jeffwatkins jeffwatkins committed May 14, 2011
Showing with 65 additions and 38 deletions.
  1. +3 −2 src/controls/ScrollView.js
  2. +17 −10 src/foundation/core/Bindable.js
  3. +45 −26 src/foundation/core/base.js
@@ -12,7 +12,8 @@ var HAS_3D= coherent.Support.CssMatrix,
NO_MOMENTUM= { dist: 0, time: 0 },
WILL_BEGIN_DRAGGING = 'scrollViewWillBeginDragging',
DID_END_DRAGGING = 'scrollViewDidEndDragging',
- DID_SCROLL = 'scrollViewDidScroll';
+ DID_SCROLL = 'scrollViewDidScroll',
+ WILL_SCROLL = 'scrollViewWillScroll';
var scrollbarID= 0;
@@ -511,7 +512,7 @@ coherent.ScrollView= Class.create(coherent.View, {
return;
}
- this.callDelegate(DID_SCROLL, this);
+ this.callDelegate(WILL_SCROLL, this);
this.moved = true;
var transitionTime = runtime || 350;
@@ -1,20 +1,26 @@
/*jsl:import kvo.js*/
-/** Bindable is a base class that provides a simple mechanism for keeping one
- object's properties in sync with the properties of another. Views and
- Controllers are subclasses of Bindable.
+/**
+ class coherent.Bindable < coherent.KVO
- @property {Object} bindings - A map of the bindings that have been
- established for this object.
+ Bindable is a base class that provides a simple mechanism for keeping one
+ object's properties in sync with the properties of another. Views and
+ Controllers are subclasses of Bindable.
+
+ @property {Object} bindings - A map of the bindings that have been
+ established for this object.
*/
coherent.Bindable= Class.create(coherent.KVO, {
- /** Construct a new Bindable instance. This initialises the bindings
- property to an empty hash.
+ /**
+ new coherent.Bindable([parameters={}])
- @param {Object} parameters - An object containing name/value pairs that
- will be copied to this object upon initialisation.
+ - parameters (Object): An optional dictionary of name/value pairs copied to
+ this object upon initialisation.
+
+ Construct a new Bindable instance. This initialises the bindings
+ property to an empty hash.
*/
constructor: function(parameters)
{
@@ -36,7 +42,8 @@ coherent.Bindable= Class.create(coherent.KVO, {
*/
maskedBindings: [],
- /** Declarative structure for placeholders based on the binding.
+ /**
+ Declarative structure for placeholders based on the binding.
For example:
defaultPlaceholders: {
@@ -44,13 +44,14 @@ coherent.typeOf=(function()
/**
coherent.compareValues(v1, v2) -> Number
- Compare two values. This handles pretty much every type possible. When the
- types don't match, the values are first converted to strings and then
- compared with a locale sensitive method.
+ - v1: first value
+ - v2: second value
- @param v1 - first value
- @param v2 - second value
- @returns {Number} -1 if v1 < v2, 0 if v1==v2, and 1 if v1>v2
+ Compare two values. This handles pretty much every type possible. When the
+ types don't match, the values are first converted to strings and then
+ compared with a locale sensitive method.
+
+ Returns -1 if v1 < v2, 0 if v1 == v2, and 1 if v1>v2.
*/
coherent.compareValues= function(v1, v2)
{
@@ -104,22 +105,32 @@ coherent.compareValues= function(v1, v2)
-/** Compare two numbers. Used to sort an array numerically instead of lexigraphically.
+/**
+ coherent.compareNumbers(left, right) -> Number
+
+ - left (Number): left value
+ - right (Number): right value
+
+ Compare two numbers. Used to sort an array numerically instead of
+ lexigraphically.
- @param {Number} left - left value
- @param {Number} right - right value
- @returns {Number} -1 if left<right, 0 if left===right, and 1 if left>right
+ Returns -1 if left<right, 0 if left===right, and 1 if left>right.
*/
coherent.compareNumbers= function(left, right)
{
return left-right;
}
-/** Compare two numbers. Used to sort an array numerically instead of lexigraphically.
+/**
+ coherent.reverseCompareNumbers(left, right) -> Number
+
+ - left (Number): left value
+ - right (Number): right value
+
+ Compare two numbers in reverse order to [coherent.compareNumbers]. Used to
+ sort an array numerically instead of lexigraphically.
- @param {Number} left - left value
- @param {Number} right - right value
- @returns {Number} 1 if left<right, 0 if left===right, and -1 if left>right
+ Returns 1 if left<right, 0 if left===right, and -1 if left>right.
*/
coherent.reverseCompareNumbers= function(left, right)
{
@@ -129,20 +140,22 @@ coherent.reverseCompareNumbers= function(left, right)
-/** Function that will create an error constructor. This takes care of
- differences between browsers, except of course that MSIE simply doesn't
- support custom error types very well. This function allows you to have a
- custom initialiser for error types simply by defining a function with the
- same name as the error type.
+/**
+ coherent.defineError(errorName) -> Function
- The return value of this function is the constructor for the new error type.
- If there's no custom constructor, this return value should be assigned to a
- global variable with the same name as the error type. That way new instances
- of the error can be created.
+ - errorName (String): The name of the error subclass -- also the name
+ of the initialiser function.
- @param {String} errorName - The name of the error subclass -- also the name
- of the initialiser function.
- @returns {Function} A function that is the constructor for the new error type.
+ Function that will create an error constructor. This takes care of
+ differences between browsers, except of course that MSIE simply doesn't
+ support custom error types very well. This function allows you to have a
+ custom initialiser for error types simply by defining a function with the
+ same name as the error type.
+
+ The return value of this function is the constructor for the new error type.
+ If there's no custom constructor, this return value should be assigned to a
+ global variable with the same name as the error type. That way new instances
+ of the error can be created.
*/
coherent.defineError= function(errorName)
{
@@ -157,6 +170,12 @@ coherent.defineError= function(errorName)
return error;
}
+/**
+ class InvalidArgumentError < Error
+
+ An error that may be thrown to signal invalid arguments were passed to a
+ function or method.
+ */
var InvalidArgumentError= coherent.defineError("InvalidArgumentError");

0 comments on commit 2993dbc

Please sign in to comment.