diff options
author | Valerio Virgillito | 2012-05-03 22:53:07 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-03 22:53:07 -0700 |
commit | 24b483db367291b72170f969de78efcb1a9b95bd (patch) | |
tree | a691a7803cefbfa76a6331a50cbeebcd16287d91 /node_modules/montage/ui/scrollview.reel | |
parent | dc93269cfa7c315d22d85c8217e2412749643f28 (diff) | |
download | ninja-24b483db367291b72170f969de78efcb1a9b95bd.tar.gz |
integrating the latest montage version
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/scrollview.reel')
-rwxr-xr-x | node_modules/montage/ui/scrollview.reel/scrollview.js | 193 |
1 files changed, 15 insertions, 178 deletions
diff --git a/node_modules/montage/ui/scrollview.reel/scrollview.js b/node_modules/montage/ui/scrollview.reel/scrollview.js index 3ac195e8..d3516d03 100755 --- a/node_modules/montage/ui/scrollview.reel/scrollview.js +++ b/node_modules/montage/ui/scrollview.reel/scrollview.js | |||
@@ -124,27 +124,7 @@ var Scrollview = exports.Scrollview = Montage.create(Component, /** @lends modul | |||
124 | this._hasMomentum = value ? true : false; | 124 | this._hasMomentum = value ? true : false; |
125 | } | 125 | } |
126 | }, | 126 | }, |
127 | /** | 127 | |
128 | Description TODO | ||
129 | @private | ||
130 | */ | ||
131 | _hasBouncing: { | ||
132 | enumerable: false, | ||
133 | value: true | ||
134 | }, | ||
135 | /** | ||
136 | Description TODO | ||
137 | @type {Function} | ||
138 | @default {Boolean} true | ||
139 | */ | ||
140 | hasBouncing: { | ||
141 | get: function () { | ||
142 | return this._hasBouncing; | ||
143 | }, | ||
144 | set: function (value) { | ||
145 | this._hasBouncing = value ? true : false; | ||
146 | } | ||
147 | }, | ||
148 | /** | 128 | /** |
149 | Description TODO | 129 | Description TODO |
150 | @private | 130 | @private |
@@ -169,30 +149,7 @@ var Scrollview = exports.Scrollview = Montage.create(Component, /** @lends modul | |||
169 | } | 149 | } |
170 | } | 150 | } |
171 | }, | 151 | }, |
172 | /** | 152 | |
173 | Description TODO | ||
174 | @private | ||
175 | */ | ||
176 | _bouncingDuration: { | ||
177 | enumerable: false, | ||
178 | value: 750 | ||
179 | }, | ||
180 | /** | ||
181 | Description TODO | ||
182 | @type {Function} | ||
183 | @default {Number} 750 | ||
184 | */ | ||
185 | bouncingDuration: { | ||
186 | get: function () { | ||
187 | return this._bouncingDuration; | ||
188 | }, | ||
189 | set: function (value) { | ||
190 | this._bouncingDuration = isNaN(parseInt(value, 10)) ? 1 : parseInt(value, 10); | ||
191 | if (this._bouncingDuration < 1) { | ||
192 | this._bouncingDuration = 1; | ||
193 | } | ||
194 | } | ||
195 | }, | ||
196 | /** | 153 | /** |
197 | Description TODO | 154 | Description TODO |
198 | @private | 155 | @private |
@@ -683,35 +640,7 @@ var Scrollview = exports.Scrollview = Montage.create(Component, /** @lends modul | |||
683 | return 3 * (k * k * t * p1y + k * tmp * p2y) + tmp * t; | 640 | return 3 * (k * k * t * p1y + k * tmp * p2y) + tmp * t; |
684 | } | 641 | } |
685 | }, | 642 | }, |
686 | /** | ||
687 | Description TODO | ||
688 | @private | ||
689 | */ | ||
690 | _bounce: { | ||
691 | enumerable: false, | ||
692 | value: function () { | ||
693 | if (this._hasBouncing) { | ||
694 | var startTime = new Date().getTime(), | ||
695 | momentum, startX = this._scrollX, startY = this._scrollY, | ||
696 | self = this; | ||
697 | |||
698 | if (startX < 0) { | ||
699 | this._animationInterval = window.setInterval(function () { | ||
700 | var time = new Date().getTime() - startTime; | ||
701 | if (time < self._bouncingDuration) { | ||
702 | var tmp = time / self._bouncingDuration; | ||
703 | 643 | ||
704 | tmp = self._bezierTValue(tmp, 0.17, 0.93, 0.19, 1); | ||
705 | self._scrollX = startX * (1 - tmp); | ||
706 | } else { | ||
707 | self._scrollX = 0; | ||
708 | window.clearInterval(self._animationInterval); | ||
709 | } | ||
710 | }, 16); | ||
711 | } | ||
712 | } | ||
713 | } | ||
714 | }, | ||
715 | /** | 644 | /** |
716 | Description TODO | 645 | Description TODO |
717 | @private | 646 | @private |
@@ -720,9 +649,7 @@ var Scrollview = exports.Scrollview = Montage.create(Component, /** @lends modul | |||
720 | enumerable: false, | 649 | enumerable: false, |
721 | value: function (event) { | 650 | value: function (event) { |
722 | 651 | ||
723 | var animateBouncingX = false, | 652 | var animateMomentum = false, |
724 | animateBouncingY = false, | ||
725 | animateMomentum = false, | ||
726 | momentumX, | 653 | momentumX, |
727 | momentumY, | 654 | momentumY, |
728 | startX = this._scrollX, | 655 | startX = this._scrollX, |
@@ -732,8 +659,6 @@ var Scrollview = exports.Scrollview = Montage.create(Component, /** @lends modul | |||
732 | endX = startX, | 659 | endX = startX, |
733 | endY, | 660 | endY, |
734 | self = this, | 661 | self = this, |
735 | startTimeBounceX = false, | ||
736 | startTimeBounceY = false, | ||
737 | startTime = new Date().getTime(); | 662 | startTime = new Date().getTime(); |
738 | 663 | ||
739 | this._nativeScrollTop = this._element.scrollTop; | 664 | this._nativeScrollTop = this._element.scrollTop; |
@@ -773,93 +698,7 @@ var Scrollview = exports.Scrollview = Montage.create(Component, /** @lends modul | |||
773 | self._scrollX = posX; | 698 | self._scrollX = posX; |
774 | self._scrollY = posY; | 699 | self._scrollY = posY; |
775 | 700 | ||
776 | if (self._hasBouncing) { | 701 | if (!animateMomentum) { |
777 | if (endX < 0) { | ||
778 | if (self._scrollX < 0) { | ||
779 | if (!startTimeBounceX) { | ||
780 | animateBouncingX = true; | ||
781 | startTimeBounceX = time; | ||
782 | } | ||
783 | t = time - startTimeBounceX; | ||
784 | if ((t < self._bouncingDuration) || (animateMomentum)) { | ||
785 | if (t > self._bouncingDuration) { | ||
786 | t = self._bouncingDuration; | ||
787 | } | ||
788 | self._scrollX = self._scrollX * (1 - self._bezierTValue(t / self._bouncingDuration, 0.17, 0.93, 0.19, 1)); | ||
789 | } else { | ||
790 | self._scrollX = 0; | ||
791 | animateBouncingX = false; | ||
792 | } | ||
793 | } else { | ||
794 | animateBouncingX = false; | ||
795 | } | ||
796 | } | ||
797 | |||
798 | if (endY < 0) { | ||
799 | if (self._scrollY < 0) { | ||
800 | if (!startTimeBounceY) { | ||
801 | animateBouncingY = true; | ||
802 | startTimeBounceY = time; | ||
803 | } | ||
804 | t = time - startTimeBounceY; | ||
805 | if ((t < self._bouncingDuration) || (animateMomentum)) { | ||
806 | if (t > self._bouncingDuration) { | ||
807 | t = self._bouncingDuration; | ||
808 | } | ||
809 | self._scrollY = self._scrollY * (1 - self._bezierTValue(t / self._bouncingDuration, 0.17, 0.93, 0.19, 1)); | ||
810 | } else { | ||
811 | self._scrollY = 0; | ||
812 | animateBouncingY = false; | ||
813 | } | ||
814 | } else { | ||
815 | animateBouncingY = false; | ||
816 | } | ||
817 | } | ||
818 | |||
819 | if (endX > self._maxScrollX) { | ||
820 | if (self._scrollX > self._maxScrollX) { | ||
821 | if (!startTimeBounceX) { | ||
822 | animateBouncingX = true; | ||
823 | startTimeBounceX = time; | ||
824 | } | ||
825 | t = time - startTimeBounceX; | ||
826 | if ((t < self._bouncingDuration) || (animateMomentum)) { | ||
827 | if (t > self._bouncingDuration) { | ||
828 | t = self._bouncingDuration; | ||
829 | } | ||
830 | self._scrollX = self._maxScrollX + (self._scrollX - self._maxScrollX) * (1 - self._bezierTValue(t / self._bouncingDuration, 0.17, 0.93, 0.19, 1)); | ||
831 | } else { | ||
832 | self._scrollX = self._maxScrollX; | ||
833 | animateBouncingX = false; | ||
834 | } | ||
835 | } else { | ||
836 | animateBouncingX = false; | ||
837 | } | ||
838 | } | ||
839 | |||
840 | if (endY > self._maxScrollY) { | ||
841 | if (self._scrollY > self._maxScrollY) { | ||
842 | if (!startTimeBounceY) { | ||
843 | animateBouncingY = true; | ||
844 | startTimeBounceY = time; | ||
845 | } | ||
846 | t = time - startTimeBounceY; | ||
847 | if ((t < self._bouncingDuration) |