From a3024011a91d3941f81481dd4d600e9684eb0fd4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 2 Feb 2012 00:11:51 -0800 Subject: upgrading to Montage v0.6 Signed-off-by: Valerio Virgillito --- .../montage/ui/scroller.reel/scroller.html | 59 ++++++++++++++- node_modules/montage/ui/scroller.reel/scroller.js | 87 +++++++++------------- 2 files changed, 94 insertions(+), 52 deletions(-) (limited to 'node_modules/montage/ui/scroller.reel') diff --git a/node_modules/montage/ui/scroller.reel/scroller.html b/node_modules/montage/ui/scroller.reel/scroller.html index 00a85a88..34e4bc0a 100644 --- a/node_modules/montage/ui/scroller.reel/scroller.html +++ b/node_modules/montage/ui/scroller.reel/scroller.html @@ -18,6 +18,63 @@ } } }, + "translateComposer1": { + "module": "montage/ui/composer/translate-composer", + "name": "TranslateComposer", + "properties": { + "component": {"@": "owner"} + }, + "bindings": { + "translateX": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "scrollX", + "oneway": false + }, + "translateY": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "scrollY", + "oneway": false + }, + "maxTranslateY": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "_maxTranslateY" + }, + "maxTranslateX": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "_maxTranslateX" + }, + "axis": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "axis" + }, + "hasBouncing": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "hasBouncing" + }, + "hasMomentum": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "hasMomentum" + }, + "bouncingDuration": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "bouncingDuration" + }, + "momentumDuration": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "momentumDuration" + } + }, + "listeners": [ + { + "type": "translateStart", + "listener": {"@": "owner"} + }, + { + "type": "translateEnd", + "listener": {"@": "owner"} + } + ] + }, "owner": { "module": "montage/ui/scroller.reel", "name": "Scroller", @@ -52,4 +109,4 @@
- \ No newline at end of file + diff --git a/node_modules/montage/ui/scroller.reel/scroller.js b/node_modules/montage/ui/scroller.reel/scroller.js index 01df7d9c..32df2906 100644 --- a/node_modules/montage/ui/scroller.reel/scroller.js +++ b/node_modules/montage/ui/scroller.reel/scroller.js @@ -1,19 +1,8 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - var Montage = require("montage").Montage, - Scroll = require("ui/scroll").Scroll, - Component = require("ui/component").Component; - -var Scroller = exports.Scroller = Montage.create(Component, { + Component = require("ui/component").Component + TranslateComposer = require("ui/composer/translate-composer").TranslateComposer; - _scroll: { - enumerable: false, - value: null - }, +exports.Scroller = Montage.create(Component, { _scrollX: { enumerable: false, @@ -45,6 +34,14 @@ var Scroller = exports.Scroller = Montage.create(Component, { } }, + _maxTranslateX: { + value: 0 + }, + + _maxTranslateY: { + value: 0 + }, + _axis: { enumerable: false, value: "auto" @@ -145,7 +142,7 @@ var Scroller = exports.Scroller = Montage.create(Component, { enumerable: false, value: null }, - + templateDidLoad: { value: function () { var orphanedFragment, @@ -156,28 +153,16 @@ var Scroller = exports.Scroller = Montage.create(Component, { this._content.appendChild(orphanedFragment); } }, - - prepareForDraw: { - value: function () { - var self = this; - - this._scroll = Montage.create(Scroll); - this._scroll.element = this._element; - this._scroll.component = this; - Object.defineBinding(this._scroll, "scrollX", {boundObject: this, boundObjectPropertyPath: "scrollX", oneway: false}); - Object.defineBinding(this._scroll, "scrollY", {boundObject: this, boundObjectPropertyPath: "scrollY", oneway: false}); - Object.defineBinding(this._scroll, "axis", {boundObject: this, boundObjectPropertyPath: "axis", oneway: false}); - Object.defineBinding(this._scroll, "hasBouncing", {boundObject: this, boundObjectPropertyPath: "hasBouncing", oneway: false}); - Object.defineBinding(this._scroll, "hasMomentum", {boundObject: this, boundObjectPropertyPath: "hasMomentum", oneway: false}); - Object.defineBinding(this._scroll, "bouncingDuration", {boundObject: this, boundObjectPropertyPath: "bouncingDuration", oneway: false}); - Object.defineBinding(this._scroll, "momentumDuration", {boundObject: this, boundObjectPropertyPath: "momentumDuration", oneway: false}); - this._scroll.deserializedFromTemplate(); - this._scroll.addEventListener("scrollStart", function () { - self._scrollBars.opacity = .5; - }, false); - this._scroll.addEventListener("scrollEnd", function () { - self._scrollBars.opacity = 0; - }, false); + + handleTranslateStart: { + value: function(event) { + this._scrollBars.opacity = .5; + } + }, + + handleTranslateEnd: { + value: function(event) { + this._scrollBars.opacity = 0; } }, @@ -188,18 +173,18 @@ var Scroller = exports.Scroller = Montage.create(Component, { this._top = this._element.offsetTop; this._width = this._element.offsetWidth; this._height = this._element.offsetHeight; - this._scroll.maxScrollX = this._content.scrollWidth - this._width; - if (this._scroll.maxScrollX < 0) { - this._scroll.maxScrollX = 0; + this._maxTranslateX = this._content.scrollWidth - this._width; + if (this._maxTranslateX < 0) { + this._.maxTranslateX = 0; } - this._scroll.maxScrollY = this._content.offsetHeight - this._height; - if (this._scroll.maxScrollY < 0) { - this._scroll.maxScrollY = 0; + this._maxTranslateY = this._content.offsetHeight - this._height; + if (this._maxTranslateY < 0) { + this._maxTranslateY = 0; } - var delegateValue = this.callDelegateMethod("didSetMaxScroll", {x: this._scroll.maxScrollX, y: this._scroll.maxScrollY}); + var delegateValue = this.callDelegateMethod("didSetMaxScroll", {x: this._maxTranslateX, y: this._maxTranslateY}); if (delegateValue) { - this._scroll.maxScrollX = delegateValue.x; - this._scroll.maxScrollY = delegateValue.y; + this._maxTranslateX = delegateValue.x; + this._maxTranslateY = delegateValue.y; } switch (this._displayScrollbars) { case "horizontal": @@ -215,15 +200,15 @@ var Scroller = exports.Scroller = Montage.create(Component, { this._scrollBars.displayVertical = true; break; case "auto": - if (this._scroll._maxScrollX && this._scroll._maxScrollY) { + if (this._maxTranslateX && this._maxTranslateY) { this._scrollBars.displayHorizontal = true; this._scrollBars.displayVertical = true; } else { - if (this._scroll._maxScrollX) { + if (this._maxTranslateX) { this._scrollBars.displayHorizontal = true; this._scrollBars.displayVertical = false; } else { - if (this._scroll._maxScrollY) { + if (this._maxTranslateY) { this._scrollBars.displayHorizontal = false; this._scrollBars.displayVertical = true; } else { @@ -255,7 +240,7 @@ var Scroller = exports.Scroller = Montage.create(Component, { this._scrollBars.verticalLength = 1; this._scrollBars.verticalScroll = 0; } - } + } } }, @@ -265,4 +250,4 @@ var Scroller = exports.Scroller = Montage.create(Component, { this._content.style.webkitTransform="translate3d("+(-this._scrollX)+"px, "+(-this._scrollY)+"px, 0)"; } } -}); \ No newline at end of file +}); -- cgit v1.2.3