Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-10539] Fixed layouts in scrollview #3817

Merged
merged 1 commit into from
Jan 29, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 26 additions & 21 deletions mobileweb/titanium/Ti/UI/ScrollView.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang", "Ti/UI"],
/*global define*/
define(['Ti/_/declare', 'Ti/_/UI/KineticScrollView', 'Ti/_/style', 'Ti/_/lang', 'Ti/UI'],
function(declare, KineticScrollView, style, lang, UI) {

var isDef = lang.isDef,

// The amount of deceleration (in pixels/ms^2)
deceleration = 0.001;

return declare("Ti.UI.ScrollView", KineticScrollView, {
return declare('Ti.UI.ScrollView', KineticScrollView, {

constructor: function(args) {
var self = this,
contentContainer,
scrollbarTimeout;
constructor: function() {
var contentContainer;
this._initKineticScrollView(contentContainer = UI.createView({
width: UI.SIZE,
height: UI.SIZE,
_minWidth: "100%",
_minHeight: "100%",
_minWidth: '100%',
_minHeight: '100%',
left: 0,
top: 0
}), "both", "both", 1);
}), 'both', 'both', 1);
},

_handleMouseWheel: function() {
this._isScrollBarActive && this.fireEvent("scroll",{
this._isScrollBarActive && this.fireEvent('scroll',{
x: -this._currentTranslationX,
y: -this._currentTranslationY,
dragging: false,
Expand All @@ -32,11 +31,11 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
},

_handleDragStart: function() {
this.fireEvent("dragStart");
this.fireEvent('dragStart');
},

_handleDrag: function() {
this.fireEvent("scroll",{
this.fireEvent('scroll',{
x: -this._currentTranslationX,
y: -this._currentTranslationY,
dragging: true,
Expand All @@ -55,13 +54,13 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
distanceY = distance * Math.sin(theta) * (velocityY < 0 ? -1 : 1),
translationX = Math.min(0, Math.max(self._minTranslationX, self._currentTranslationX + distanceX)),
translationY = Math.min(0, Math.max(self._minTranslationY, self._currentTranslationY + distanceY));
self.fireEvent("dragEnd",{
self.fireEvent('dragEnd',{
decelerate: true
});
self._animateToPosition(translationX, translationY, duration, UI.ANIMATION_CURVE_EASE_OUT, function() {
self._setTranslation(translationX, translationY);
self._endScrollBars();
self.fireEvent("scrollEnd");
self.fireEvent('scrollEnd');
});
}
},
Expand All @@ -79,7 +78,7 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
},

_preLayout: function() {
var needsRecalculation = this._contentContainer.layout === this.layout
var needsRecalculation = this._contentContainer.layout === this.layout;
this._contentContainer.layout = this.layout;
return needsRecalculation;
},
Expand All @@ -96,7 +95,7 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",

properties: {
contentHeight: {
get: function(value) {
get: function() {
return this._contentContainer.height;
},
set: function(value) {
Expand All @@ -106,7 +105,7 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
},

contentOffset: {
get: function(value) {
get: function() {
return {
x: -this._currentTranslationX,
y: -this._currentTranslationY
Expand All @@ -120,24 +119,30 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
},

contentWidth: {
get: function(value) {
get: function() {
return this._contentContainer.width;
},
set: function(value) {
this._contentContainer.width = value;
return value;
}
},

disableBounce: false,

horizontalBounce: {
set: function(value) {
return this._horizontalElastic = value;
},
value: true
},

layout: {
set: function(value) {
return this._contentContainer.layout = value;
}
},

showHorizontalScrollIndicator: {
set: function(value, oldValue) {
if (value !== oldValue) {
Expand Down Expand Up @@ -165,7 +170,7 @@ define(["Ti/_/declare", "Ti/_/UI/KineticScrollView", "Ti/_/style", "Ti/_/lang",
},
value: true
},

verticalBounce: {
set: function(value) {
return this._verticalElastic = value;
Expand Down