Skip to content

Commit

Permalink
Merge branch 'integration'
Browse files Browse the repository at this point in the history
  • Loading branch information
derek committed Sep 12, 2012
2 parents e146098 + 203268c commit 980952e
Show file tree
Hide file tree
Showing 17 changed files with 787 additions and 545 deletions.
428 changes: 239 additions & 189 deletions build/scrollview-base/scrollview-base-coverage.js

Large diffs are not rendered by default.

57 changes: 48 additions & 9 deletions build/scrollview-base/scrollview-base-debug.js
Expand Up @@ -306,7 +306,7 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {

sv._set(AXIS, sv._cAxis);
}

// get text direction on or inherited by scrollview node
sv.rtl = (sv._cb.getComputedStyle('direction') === 'rtl');

Expand Down Expand Up @@ -334,6 +334,12 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
cb = sv._cb,
bb = sv._bb,
TRANS = ScrollView._TRANSITION,
// Ideally using CSSMatrix - don't think we have it normalized yet though.
// origX = (new WebKitCSSMatrix(cb.getComputedStyle("transform"))).e,
// origY = (new WebKitCSSMatrix(cb.getComputedStyle("transform"))).f,
origX = sv.get(SCROLL_X),
origY = sv.get(SCROLL_Y),
HWTransform,
dims;

// TODO: Is this OK? Just in case it's called 'during' a transition.
Expand All @@ -342,12 +348,19 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
cb.setStyle(TRANS.PROPERTY, EMPTY);
}

origHWTransform = sv._forceHWTransforms;
sv._forceHWTransforms = false; // the z translation was causing issues with picking up accurate scrollWidths in Chrome/Mac.

sv._moveTo(cb, 0, 0);
dims = {
'offsetWidth': bb.get('offsetWidth'),
'offsetHeight': bb.get('offsetHeight'),
'scrollWidth': bb.get('scrollWidth'),
'scrollHeight': bb.get('scrollHeight')
};
sv._moveTo(cb, -(origX), -(origY));

sv._forceHWTransforms = origHWTransform;

return dims;
},
Expand Down Expand Up @@ -422,8 +435,8 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
* @param x {Number} The x-position to scroll to. (null for no movement)
* @param y {Number} The y-position to scroll to. (null for no movement)
* @param {Number} [duration] ms of the scroll animation. (default is 0)
* @param {String} [easing] An easing equation if duration is set. (defaults to ScrollView.EASING)
* @param {String} [node] The node to move.
* @param {String} [easing] An easing equation if duration is set. (default is `easing` attribute)
* @param {String} [node] The node to transform. Setting this can be useful in dual-axis paginated instances. (default is the instance's contentBox)
*/
scrollTo: function (x, y, duration, easing, node) {
// Check to see if widget is disabled
Expand Down Expand Up @@ -516,6 +529,25 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
return prop;
},

/**
* Utility method, to move the given element to the given xy position
*
* @method _moveTo
* @param node {Node} The node to move
* @param x {Number} The x-position to move to
* @param y {Number} The y-position to move to
* @private
*/
_moveTo : function(node, x, y) {
if (NATIVE_TRANSITIONS) {
node.setStyle('transform', this._transform(x, y));
} else {
node.setStyle(LEFT, x + PX);
node.setStyle(TOP, y + PX);
}
},


/**
* Content box transition callback
*
Expand Down Expand Up @@ -713,15 +745,18 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
}

var sv = this,
gesture = sv._gesture,
svAxis = sv._cAxis,
flick = e.flick,
flickAxis = flick.axis,
flickVelocity = flick.velocity,
axisAttr = flickAxis === DIM_X ? SCROLL_X : SCROLL_Y,
startPosition = sv.get(axisAttr);

gesture.flick = flick;
// Sometimes flick is enabled, but drag is disabled
if (sv._gesture) {
sv._gesture.flick = flick;
}

// Prevent unneccesary firing of _flickFrame if we can't scroll on the flick axis
if (svAxis[flickAxis]) {
sv._flickFrame(flickVelocity, flickAxis, startPosition);
Expand Down Expand Up @@ -819,8 +854,12 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {

scrollToY = _constrain(scrollToY, sv._minScrollY, sv._maxScrollY);

if (bb.contains(e.target)) {

// Because Mousewheel events fire off 'document', every ScrollView widget will react
// to any mousewheel anywhere on the page. This check will ensure that the mouse is currently
// over this specific ScrollView. Also, only allow mousewheel scrolling on Y-axis,
// becuase otherwise the 'prevent' will block page scrolling.
if (bb.contains(e.target) && sv._cAxis[DIM_Y]) {

// Reset lastScrolledAmt
sv.lastScrolledAmt = 0;

Expand Down Expand Up @@ -1130,7 +1169,7 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
},

/**
* The scroll position in the x-axis
* The current scroll position in the x-axis
*
* @attribute scrollX
* @type Number
Expand All @@ -1142,7 +1181,7 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
},

/**
* The scroll position in the y-axis
* The current scroll position in the y-axis
*
* @attribute scrollY
* @type Number
Expand Down
4 changes: 2 additions & 2 deletions build/scrollview-base/scrollview-base-min.js

Large diffs are not rendered by default.

57 changes: 48 additions & 9 deletions build/scrollview-base/scrollview-base.js
Expand Up @@ -306,7 +306,7 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {

sv._set(AXIS, sv._cAxis);
}

// get text direction on or inherited by scrollview node
sv.rtl = (sv._cb.getComputedStyle('direction') === 'rtl');

Expand Down Expand Up @@ -334,6 +334,12 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
cb = sv._cb,
bb = sv._bb,
TRANS = ScrollView._TRANSITION,
// Ideally using CSSMatrix - don't think we have it normalized yet though.
// origX = (new WebKitCSSMatrix(cb.getComputedStyle("transform"))).e,
// origY = (new WebKitCSSMatrix(cb.getComputedStyle("transform"))).f,
origX = sv.get(SCROLL_X),
origY = sv.get(SCROLL_Y),
HWTransform,
dims;

// TODO: Is this OK? Just in case it's called 'during' a transition.
Expand All @@ -342,12 +348,19 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
cb.setStyle(TRANS.PROPERTY, EMPTY);
}

origHWTransform = sv._forceHWTransforms;
sv._forceHWTransforms = false; // the z translation was causing issues with picking up accurate scrollWidths in Chrome/Mac.

sv._moveTo(cb, 0, 0);
dims = {
'offsetWidth': bb.get('offsetWidth'),
'offsetHeight': bb.get('offsetHeight'),
'scrollWidth': bb.get('scrollWidth'),
'scrollHeight': bb.get('scrollHeight')
};
sv._moveTo(cb, -(origX), -(origY));

sv._forceHWTransforms = origHWTransform;

return dims;
},
Expand Down Expand Up @@ -422,8 +435,8 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
* @param x {Number} The x-position to scroll to. (null for no movement)
* @param y {Number} The y-position to scroll to. (null for no movement)
* @param {Number} [duration] ms of the scroll animation. (default is 0)
* @param {String} [easing] An easing equation if duration is set. (defaults to ScrollView.EASING)
* @param {String} [node] The node to move.
* @param {String} [easing] An easing equation if duration is set. (default is `easing` attribute)
* @param {String} [node] The node to transform. Setting this can be useful in dual-axis paginated instances. (default is the instance's contentBox)
*/
scrollTo: function (x, y, duration, easing, node) {
// Check to see if widget is disabled
Expand Down Expand Up @@ -516,6 +529,25 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
return prop;
},

/**
* Utility method, to move the given element to the given xy position
*
* @method _moveTo
* @param node {Node} The node to move
* @param x {Number} The x-position to move to
* @param y {Number} The y-position to move to
* @private
*/
_moveTo : function(node, x, y) {
if (NATIVE_TRANSITIONS) {
node.setStyle('transform', this._transform(x, y));
} else {
node.setStyle(LEFT, x + PX);
node.setStyle(TOP, y + PX);
}
},


/**
* Content box transition callback
*
Expand Down Expand Up @@ -713,15 +745,18 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
}

var sv = this,
gesture = sv._gesture,
svAxis = sv._cAxis,
flick = e.flick,
flickAxis = flick.axis,
flickVelocity = flick.velocity,
axisAttr = flickAxis === DIM_X ? SCROLL_X : SCROLL_Y,
startPosition = sv.get(axisAttr);

gesture.flick = flick;
// Sometimes flick is enabled, but drag is disabled
if (sv._gesture) {
sv._gesture.flick = flick;
}

// Prevent unneccesary firing of _flickFrame if we can't scroll on the flick axis
if (svAxis[flickAxis]) {
sv._flickFrame(flickVelocity, flickAxis, startPosition);
Expand Down Expand Up @@ -819,8 +854,12 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {

scrollToY = _constrain(scrollToY, sv._minScrollY, sv._maxScrollY);

if (bb.contains(e.target)) {

// Because Mousewheel events fire off 'document', every ScrollView widget will react
// to any mousewheel anywhere on the page. This check will ensure that the mouse is currently
// over this specific ScrollView. Also, only allow mousewheel scrolling on Y-axis,
// becuase otherwise the 'prevent' will block page scrolling.
if (bb.contains(e.target) && sv._cAxis[DIM_Y]) {

// Reset lastScrolledAmt
sv.lastScrolledAmt = 0;

Expand Down Expand Up @@ -1130,7 +1169,7 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
},

/**
* The scroll position in the x-axis
* The current scroll position in the x-axis
*
* @attribute scrollX
* @type Number
Expand All @@ -1142,7 +1181,7 @@ Y.ScrollView = Y.extend(ScrollView, Y.Widget, {
},

/**
* The scroll position in the y-axis
* The current scroll position in the y-axis
*
* @attribute scrollY
* @type Number
Expand Down
294 changes: 158 additions & 136 deletions build/scrollview-paginator/scrollview-paginator-coverage.js

Large diffs are not rendered by default.

45 changes: 32 additions & 13 deletions build/scrollview-paginator/scrollview-paginator-debug.js
Expand Up @@ -91,6 +91,7 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
// Host method listeners
paginator.beforeHostMethod('scrollTo', paginator._beforeHostScrollTo);
paginator.beforeHostMethod('_mousewheel', paginator._beforeHostMousewheel);
paginator.beforeHostMethod('_flick', paginator._beforeHostFlick);
paginator.afterHostMethod('_onGestureMoveEnd', paginator._afterHostGestureMoveEnd);
paginator.afterHostMethod('_uiDimensionsChange', paginator._afterHostUIDimensionsChange);
paginator.afterHostMethod('syncUI', paginator._afterHostSyncUI);
Expand Down Expand Up @@ -151,19 +152,17 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
var paginator = this,
host = paginator._host,
hostFlick = host.get(FLICK),
pageNodes = paginator._getPageNodes(),
size = pageNodes.size(),
paginatorAxis;

// Set the page count
paginator.set(TOTAL, size);

// If paginator's 'axis' property is to be automatically determined, inherit host's property
if (paginator._cAxis === undefined) {
paginator._set(AXIS, host.get(AXIS));
}

paginatorAxis = paginator.get(AXIS);

// Don't allow flicks on the paginated axis
if (paginatorAxis[hostFlick.axis]) {
host.set(FLICK, false);
}
},

/**
Expand All @@ -177,9 +176,9 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {

var paginator = this,
host = paginator._host,
bb = paginator._bb,
widgetWidth = bb.get('offsetWidth'),
widgetHeight = bb.get('offsetHeight'),
dims = host._getScrollDims(),
widgetWidth = dims.offsetWidth,
widgetHeight = dims.offsetHeight,
pageNodes = paginator._getPageNodes();

// Inefficient. Should not reinitialize every page every syncUI
Expand Down Expand Up @@ -318,6 +317,25 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
}
},

/**
* Executed before host._flick
* Prevents flick events in some conditions
*
* @method _beforeHostFlick
* @param {Event.Facade}
* @protected
*/
_beforeHostFlick: function (e) {
var paginator = this,
paginatorAxis = paginator.get(AXIS),
flickAxis = e.flick.axis || false;

// Prevent flicks on the paginated axis
if (paginatorAxis[flickAxis]) {
return new Y.Do.Prevent();
}
},

/**
* Executes after host's 'scrollEnd' event
* Runs cleanup operations
Expand Down Expand Up @@ -461,7 +479,7 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
},

/**
* Scroll to the next page in the scrollview, with animation
* Scroll to the next page, with animation
*
* @method next
*/
Expand All @@ -480,7 +498,7 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
},

/**
* Scroll to the previous page in the scrollview, with animation
* Scroll to the previous page, with animation
*
* @method prev
*/
Expand Down Expand Up @@ -607,7 +625,8 @@ Y.extend(PaginatorPlugin, Y.Plugin.Base, {
ATTRS: {

/**
* Specifies ability to scroll on x, y, or x and y axis/axes.
* Specifies ability to scroll on x, y, or x and y axis/axes.
* If unspecified, it inherits from the host instance.
*
* @attribute axis
* @type String
Expand Down

0 comments on commit 980952e

Please sign in to comment.