diff --git a/dist/css/ionic-ios7.css b/dist/css/ionic-ios7.css index 4c2bacd541..f721e134f9 100644 --- a/dist/css/ionic-ios7.css +++ b/dist/css/ionic-ios7.css @@ -182,7 +182,7 @@ sub { fieldset { margin: 0 2px; padding: 0.35em 0.625em 0.75em; - border: 1px solid #c0c0c0; } + border: 1px solid silver; } /** * 1. Correct `color` not being inherited in IE 8/9. @@ -558,7 +558,7 @@ a.subdued‎ { &.bar-footer { border-top-width: 1px; }*/ - box-shadow: inset 0 0 1px #999; } + box-shadow: inset 0 0 1px #999999; } .bar.bar-clear { border: none; background: none; @@ -1659,7 +1659,7 @@ input[type="file"] { line-height: 34px; } select { - border: 1px solid #ccc; + border: 1px solid #cccccc; background-color: white; } select[multiple], @@ -1731,7 +1731,7 @@ input[type="checkbox"][readonly] { right: 20px; transition: 0.2s ease; transition-property: left, right; - transition-delay: 0s, .05s; } + transition-delay: 0s, 0.05s; } .toggle :checked + .track { /* When the toggle is "on" */ @@ -1746,7 +1746,7 @@ input[type="checkbox"][readonly] { right: 0; left: 20px; -webkit-transform: none; - transition-delay: .05s, 0s; } + transition-delay: 0.05s, 0s; } .item-radio { padding: 0; } @@ -2021,7 +2021,7 @@ input[type="range"] { .button.button-icon:active, .button.button-icon.active { background: none; box-shadow: none; - text-shadow: 0px 0px 10px #fff; } + text-shadow: 0px 0px 10px white; } .button.block, .button.button-full { margin-top: 10px; margin-bottom: 10px; } @@ -2363,9 +2363,9 @@ a.button { line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - -webkit-animation: spin .75s linear infinite; - -moz-animation: spin .75s linear infinite; - animation: spin .75s linear infinite; } + -webkit-animation: spin 0.75s linear infinite; + -moz-animation: spin 0.75s linear infinite; + animation: spin 0.75s linear infinite; } .icon-loading:before { content: "\e144"; } @@ -2378,9 +2378,9 @@ a.button { line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - -webkit-animation: spin .75s linear infinite; - -moz-animation: spin .75s linear infinite; - animation: spin .75s linear infinite; } + -webkit-animation: spin 0.75s linear infinite; + -moz-animation: spin 0.75s linear infinite; + animation: spin 0.75s linear infinite; } .icon-refreshing:before { content: "\e144"; } diff --git a/dist/css/ionic-scoped.css b/dist/css/ionic-scoped.css index b5674260e2..a57a23bd7d 100644 --- a/dist/css/ionic-scoped.css +++ b/dist/css/ionic-scoped.css @@ -1027,7 +1027,7 @@ .ionic fieldset { margin: 0 2px; padding: 0.35em 0.625em 0.75em; - border: 1px solid #c0c0c0; } + border: 1px solid silver; } .ionic legend { padding: 0; /* 2 */ @@ -1324,7 +1324,7 @@ &.bar-footer { border-top-width: 1px; }*/ - box-shadow: inset 0 0 1px #999; } + box-shadow: inset 0 0 1px #999999; } .ionic .bar.bar-clear { border: none; background: none; @@ -2315,7 +2315,7 @@ .ionic input[type="file"] { line-height: 34px; } .ionic select { - border: 1px solid #ccc; + border: 1px solid #cccccc; background-color: white; } .ionic select[multiple], .ionic select[size] { @@ -2364,7 +2364,7 @@ border-radius: 50%; background: white; content: ' '; - transition: background-color .1s ease-in-out; } + transition: background-color 0.1s ease-in-out; } .ionic .checkbox input:after { position: absolute; top: 34%; @@ -2377,7 +2377,7 @@ border-right: 0; content: ' '; opacity: 0; - transition: opacity .05s ease-in-out; + transition: opacity 0.05s ease-in-out; -webkit-transform: rotate(-45deg); transform: rotate(-45deg); } .ionic .checkbox input:checked:before { @@ -2719,7 +2719,7 @@ .ionic .button.button-icon:active, .ionic .button.button-icon.active { background: none; box-shadow: none; - text-shadow: 0px 0px 10px #fff; } + text-shadow: 0px 0px 10px white; } .ionic .button.block, .ionic .button.button-full { margin-top: 10px; margin-bottom: 10px; } @@ -2971,9 +2971,9 @@ line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - -webkit-animation: spin .75s linear infinite; - -moz-animation: spin .75s linear infinite; - animation: spin .75s linear infinite; } + -webkit-animation: spin 0.75s linear infinite; + -moz-animation: spin 0.75s linear infinite; + animation: spin 0.75s linear infinite; } .ionic .icon-loading:before { content: "\e144"; } .ionic .icon-refreshing { @@ -2985,9 +2985,9 @@ line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - -webkit-animation: spin .75s linear infinite; - -moz-animation: spin .75s linear infinite; - animation: spin .75s linear infinite; } + -webkit-animation: spin 0.75s linear infinite; + -moz-animation: spin 0.75s linear infinite; + animation: spin 0.75s linear infinite; } .ionic .icon-refreshing:before { content: "\e144"; } .ionic .hidden, diff --git a/dist/css/ionic.css b/dist/css/ionic.css index 037c254ec4..e44f117a0c 100644 --- a/dist/css/ionic.css +++ b/dist/css/ionic.css @@ -1261,7 +1261,7 @@ sub { fieldset { margin: 0 2px; padding: 0.35em 0.625em 0.75em; - border: 1px solid #c0c0c0; } + border: 1px solid silver; } /** * 1. Correct `color` not being inherited in IE 8/9. @@ -1667,7 +1667,7 @@ a.subdued‎ { &.bar-footer { border-top-width: 1px; }*/ - box-shadow: inset 0 0 1px #999; } + box-shadow: inset 0 0 1px #999999; } .bar.bar-clear { border: none; background: none; @@ -2802,7 +2802,7 @@ input[type="file"] { line-height: 34px; } select { - border: 1px solid #ccc; + border: 1px solid #cccccc; background-color: white; } select[multiple], @@ -2857,7 +2857,7 @@ input[type="checkbox"][readonly] { border-radius: 50%; background: white; content: ' '; - transition: background-color .1s ease-in-out; } + transition: background-color 0.1s ease-in-out; } /* the checkmark within the box */ .checkbox input:after { @@ -2872,7 +2872,7 @@ input[type="checkbox"][readonly] { border-right: 0; content: ' '; opacity: 0; - transition: opacity .05s ease-in-out; + transition: opacity 0.05s ease-in-out; -webkit-transform: rotate(-45deg); transform: rotate(-45deg); } @@ -3242,7 +3242,7 @@ input[type="range"] { .button.button-icon:active, .button.button-icon.active { background: none; box-shadow: none; - text-shadow: 0px 0px 10px #fff; } + text-shadow: 0px 0px 10px white; } .button.block, .button.button-full { margin-top: 10px; margin-bottom: 10px; } @@ -3689,9 +3689,9 @@ a.button { line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - -webkit-animation: spin .75s linear infinite; - -moz-animation: spin .75s linear infinite; - animation: spin .75s linear infinite; } + -webkit-animation: spin 0.75s linear infinite; + -moz-animation: spin 0.75s linear infinite; + animation: spin 0.75s linear infinite; } .icon-loading:before { content: "\e144"; } @@ -3704,9 +3704,9 @@ a.button { line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - -webkit-animation: spin .75s linear infinite; - -moz-animation: spin .75s linear infinite; - animation: spin .75s linear infinite; } + -webkit-animation: spin 0.75s linear infinite; + -moz-animation: spin 0.75s linear infinite; + animation: spin 0.75s linear infinite; } .icon-refreshing:before { content: "\e144"; } diff --git a/dist/js/ionic.js b/dist/js/ionic.js index cfe41b351d..4606aba909 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -1794,6 +1794,604 @@ window.ionic = { })(window.ionic); ; (function(ionic) { +'use strict'; + ionic.views.View = function() { + this.initialize.apply(this, arguments); + }; + + ionic.views.View.inherit = ionic.inherit; + + ionic.extend(ionic.views.View.prototype, { + initialize: function() {} + }); + +})(window.ionic); +; +/** + * ionic.views.Scroll. Portions adapted from the great iScroll 5, which is + * also MIT licensed. + * iScroll v5.0.5 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license + * + * Think of ionic.views.Scroll like a Javascript version of UIScrollView or any + * scroll container in any UI library. You could just use -webkit-overflow-scrolling: touch, + * but you lose control over scroll behavior that native developers have with things + * like UIScrollView, and you don't get events after the finger stops touching the + * device (after a flick, for example). + * + * Some people are afraid of using Javascript powered scrolling, but + * with today's devices, Javascript is probably the best solution for + * scrolling in hybrid apps. + */ +(function(ionic) { +'use strict'; + var EASING_FUNCTIONS = { + quadratic: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', + circular: 'cubic-bezier(0.1, 0.57, 0.1, 1)', + circular2: 'cubic-bezier(0.075, 0.82, 0.165, 1)', + + bounce: 'cubic-bezier(.02,.69,.67,1)', + + // It closes like a high-end toilet seat. Fast, then nice and slow. + // Thanks to our @xtheglobe for that. + toiletSeat: 'cubic-bezier(0.05, 0.60, 0.05, 0.60)' + }; + + ionic.views.Scroll = ionic.views.View.inherit({ + initialize: function(opts) { + var _this = this; + + // Extend the options with our defaults + opts = ionic.Utils.extend({ + decelerationRate: ionic.views.Scroll.prototype.DECEL_RATE_NORMAL, + dragThreshold: 10, + resistance: 2, + scrollEventName: 'momentumScrolled', + scrollEndEventName: 'momentumScrollEnd', + inertialEventInterval: 50, + mouseWheelSpeed: 20, + invertWheel: false, + isVerticalEnabled: true, + isHorizontalEnabled: false, + bounceEasing: EASING_FUNCTIONS.bounce, + bounceTime: 600 //how long to take when bouncing back in a rubber band + }, opts); + + ionic.extend(this, opts); + + this.el = opts.el; + + this.y = 0; + this.x = 0; + + // Listen for drag and release events + ionic.onGesture('drag', function(e) { + _this._handleDrag(e); + }, this.el); + ionic.onGesture('release', function(e) { + _this._handleEndDrag(e); + }, this.el); + ionic.on('mousewheel', function(e) { + _this._wheel(e); + }, this.el); + ionic.on('DOMMouseScroll', function(e) { + _this._wheel(e); + }, this.el); + ionic.on(this.scrollEndEventName, function(e) { + _this._onScrollEnd(e); + }, this.el); + ionic.on('webkitTransitionEnd', function(e) { + _this._onTransitionEnd(e); + }); + }, + + /** + * Scroll to the given X and Y point, taking + * the given amount of time, with the given + * easing function defined as a CSS3 timing function. + * + * @param {float} the x position to scroll to (CURRENTLY NOT SUPPORTED!) + * @param {float} the y position to scroll to + * @param {float} the time to take scrolling to the new position + * @param {easing} the animation function to use for easing + */ + scrollTo: function(x, y, time, easing) { + var _this = this; + + + easing = easing || 'cubic-bezier(0.1, 0.57, 0.1, 1)'; + + var ox = x, oy = y; + + var el = this.el; + + if(x !== null) { + this.x = x; + } else { + x = this.x; + } + if(y !== null) { + this.y = y; + } else { + y = this.y; + } + + el.offsetHeight; + el.style.webkitTransitionTimingFunction = easing; + el.style.webkitTransitionDuration = time; + el.style.webkitTransform = 'translate3d(' + x + 'px,' + y + 'px, 0)'; + + clearTimeout(this._momentumStepTimeout); + // Start triggering events as the element scrolls from inertia. + // This is important because we need to receive scroll events + // even after a "flick" and adjust, etc. + this._momentumStepTimeout = setTimeout(function eventNotify() { + var trans = _this.el.style.webkitTransform.replace('translate3d(', '').split(','); + var scrollLeft = parseFloat(trans[0] || 0); + var scrollTop = parseFloat(trans[1] || 0); + + _this.didScroll && _this.didScroll({ + target: _this.el, + scrollLeft: -scrollLeft, + scrollTop: -scrollTop + }); + ionic.trigger(_this.scrollEventName, { + target: _this.el, + scrollLeft: -scrollLeft, + scrollTop: -scrollTop + }); + + if(_this._isDragging) { + _this._momentumStepTimeout = setTimeout(eventNotify, _this.inertialEventInterval); + } + }, this.inertialEventInterval) + }, + + needsWrapping: function() { + var _this = this; + + var totalWidth = this.el.scrollWidth; + var totalHeight = this.el.scrollHeight; + var parentWidth = this.el.parentNode.offsetWidth; + var parentHeight = this.el.parentNode.offsetHeight; + + var maxX = Math.min(0, (-totalWidth + parentWidth)); + var maxY = Math.min(0, (-totalHeight + parentHeight)); + + if (this.isHorizontalEnabled && (this.x > 0 || this.x < maxX)) { + return true; + } + + if (this.isVerticalEnabled && (this.y > 0 || this.y < maxY)) { + return true; + } + + return false; + }, + + /** + * If the scroll position is outside the current bounds, + * animate it back. + */ + wrapScrollPosition: function(transitionTime) { + var _this = this; + + var totalWidth = _this.el.scrollWidth; + var totalHeight = _this.el.scrollHeight; + var parentWidth = _this.el.parentNode.offsetWidth; + var parentHeight = _this.el.parentNode.offsetHeight; + + var maxX = Math.min(0, (-totalWidth + parentWidth)); + var maxY = Math.min(0, (-totalHeight + parentHeight)); + + //this._execEvent('scrollEnd'); + var x = _this.x, y = _this.y; + + if (!_this.isHorizontalEnabled || _this.x > 0) { + x = 0; + } else if ( _this.x < maxX) { + x = maxX; + } + + if (!_this.isVerticalEnabled || _this.y > 0) { + y = 0; + } else if (_this.y < maxY) { + y = maxY; + } + + // No change + if (x == _this.x && y == _this.y) { + return false; + } + _this.scrollTo(x, y, transitionTime || 0, _this.bounceEasing); + + return true; + }, + + _wheel: function(e) { + var wheelDeltaX, wheelDeltaY, + newX, newY, + that = this; + + var totalWidth = this.el.scrollWidth; + var totalHeight = this.el.scrollHeight; + var parentWidth = this.el.parentNode.offsetWidth; + var parentHeight = this.el.parentNode.offsetHeight; + + var maxX = Math.min(0, (-totalWidth + parentWidth)); + var maxY = Math.min(0, (-totalHeight + parentHeight)); + + // Execute the scrollEnd event after 400ms the wheel stopped scrolling + clearTimeout(this.wheelTimeout); + this.wheelTimeout = setTimeout(function () { + ionic.trigger(this.scrollEndEventName, { + target: this.el, + scrollLeft: this.x, + scrollTop: this.y + }); + }, 400); + + e.preventDefault(); + + if('wheelDeltaX' in e) { + wheelDeltaX = e.wheelDeltaX / 120; + wheelDeltaY = e.wheelDeltaY / 120; + } else if ('wheelDelta' in e) { + wheelDeltaX = wheelDeltaY = e.wheelDelta / 120; + } else if ('detail' in e) { + wheelDeltaX = wheelDeltaY = -e.detail / 3; + } else { + return; + } + + wheelDeltaX *= this.mouseWheelSpeed; + wheelDeltaY *= this.mouseWheelSpeed; + + if(!this.isVerticalEnabled) { + wheelDeltaX = wheelDeltaY; + wheelDeltaY = 0; + } + + newX = this.x + (this.isHorizontalEnabled ? wheelDeltaX * (this.invertWheel ? -1 : 1) : 0); + newY = this.y + (this.isVerticalEnabled ? wheelDeltaY * (this.invertWheel ? -1 : 1) : 0); + + if(newX > 0) { + newX = 0; + } else if (newX < maxX) { + newX = maxX; + } + + if(newY > 0) { + newY = 0; + } else if (newY < maxY) { + newY = maxY; + } + + this.scrollTo(newX, newY, 0); + }, + + _getMomentum: function (current, start, time, lowerMargin, wrapperSize) { + var distance = current - start, + speed = Math.abs(distance) / time, + destination, + duration, + deceleration = 0.0006; + + // Calculate the final desination + destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); + duration = speed / deceleration; + + // Check if the final destination needs to be rubber banded + if ( destination < lowerMargin ) { + // We have dragged too far down, snap back to the maximum + destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin; + distance = Math.abs(destination - current); + duration = distance / speed; + } else if ( destination > 0 ) { + + // We have dragged too far up, snap back to 0 + destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0; + distance = Math.abs(current) + destination; + duration = distance / speed; + } + + return { + destination: Math.round(destination), + duration: duration + }; + }, + + _onTransitionEnd: function(e) { + var _this = this; + + if (e.target != this.el) { + return; + } + + var needsWrapping = this.needsWrapping(); + + // Triggered to end scroll, once the final animation has ended + if(needsWrapping && this._didEndScroll) { + this._didEndScroll = false; + ionic.trigger(this.scrollEndEventName, { + target: this.el, + scrollLeft: this.x, + scrollTop: this.y + }); + } else if(!needsWrapping) { + this._didEndScroll = false; + ionic.trigger(this.scrollEndEventName, { + target: this.el, + scrollLeft: this.x, + scrollTop: this.y + }); + } + + this.el.style.webkitTransitionDuration = '0'; + + window.requestAnimationFrame(function() { + if(_this.wrapScrollPosition(_this.bounceTime)) { + _this._didEndScroll = true; + } + }); + }, + + _onScrollEnd: function() { + this._isDragging = false; + this._drag = null; + this.el.classList.remove('scroll-scrolling'); + + this.el.style.webkitTransitionDuration = '0'; + + clearTimeout(this._momentumStepTimeout) + }, + + + _initDrag: function() { + this._onScrollEnd(); + this._isStopped = false; + }, + + + /** + * Initialize a drag by grabbing the content area to drag, and any other + * info we might need for the dragging. + */ + _startDrag: function(e) { + var offsetX, content; + + this._initDrag(); + + var scrollLeft = parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[0]) || 0; + var scrollTop = parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[1]) || 0; + + var totalWidth = this.el.scrollWidth; + var totalHeight = this.el.scrollHeight; + var parentWidth = this.el.parentNode.offsetWidth; + var parentHeight = this.el.parentNode.offsetHeight; + + var maxX = Math.min(0, (-totalWidth + parentWidth)); + var maxY = Math.min(0, (-totalHeight + parentHeight)); + + // Check if we even have enough content to scroll, if not, don't start the drag + if((this.isHorizontalEnabled && maxX == 0) || (this.isVerticalEnabled && maxY == 0)) { + return; + } + + this.x = scrollLeft; + this.y = scrollTop; + + this._drag = { + direction: 'v', + pointX: e.gesture.touches[0].pageX, + pointY: e.gesture.touches[0].pageY, + startX: scrollLeft, + startY: scrollTop, + resist: 1, + startTime: Date.now() + }; + }, + + + + /** + * Process the drag event to move the item to the left or right. + * + * This function needs to be as fast as possible to make sure scrolling + * performance is high. + */ + _handleDrag: function(e) { + var _this = this; + + var content; + + // The drag stopped already, don't process this one + if(_this._isStopped) { + _this._initDrag(); + return; + } + + // We really aren't dragging + if(!_this._drag) { + _this._startDrag(e); + if(!_this._drag) { return; } + } + + // Stop any default events during the drag + e.preventDefault(); + + var px = e.gesture.touches[0].pageX; + var py = e.gesture.touches[0].pageY; + + var deltaX = px - _this._drag.pointX; + var deltaY = py - _this._drag.pointY; + + _this._drag.pointX = px; + _this._drag.pointY = py; + + // Check if we should start dragging. Check if we've dragged past the threshold. + if(!_this._isDragging && + ((Math.abs(e.gesture.deltaY) > _this.dragThreshold) || + (Math.abs(e.gesture.deltaX) > _this.dragThreshold))) { + _this._isDragging = true; + } + + if(_this._isDragging) { + var drag = _this._drag; + + // Request an animation frame to batch DOM reads/writes + window.requestAnimationFrame(function() { + // We are dragging, grab the current content height + + var totalWidth = _this.el.scrollWidth; + var totalHeight = _this.el.scrollHeight; + var parentWidth = _this.el.parentNode.offsetWidth; + var parentHeight = _this.el.parentNode.offsetHeight; + var maxX = Math.min(0, (-totalWidth + parentWidth)); + var maxY = Math.min(0, (-totalHeight + parentHeight)); + + // Grab current timestamp to keep our speend, etc. + // calculations in a window + var timestamp = Date.now(); + + // Calculate the new Y point for the container + // TODO: Only enable certain axes + var newX = _this.x + deltaX; + var newY = _this.y + deltaY; + + if(newX > 0 || (-newX + parentWidth) > totalWidth) { + // Rubber band + newX = _this.x + deltaX / 3; + } + // Check if the dragging is beyond the bottom or top + if(newY > 0 || (-newY + parentHeight) > totalHeight) { + // Rubber band + newY = _this.y + deltaY / 3;//(-_this.resistance); + } + + if(!_this.isHorizontalEnabled) { + newX = 0; + } + if(!_this.isVerticalEnabled) { + newY = 0; + } + + // Update the new translated Y point of the container + _this.el.style.webkitTransform = 'translate3d(' + newX + 'px,' + newY + 'px, 0)'; + + // Store the last points + _this.x = newX; + _this.y = newY; + + // Check if we need to reset the drag initial states if we've + // been dragging for a bit + if(timestamp - drag.startTime > 300) { + drag.startTime = timestamp; + drag.startX = _this.x; + drag.startY = _this.y; + } + + _this.didScroll && _this.didScroll({ + target: _this.el, + scrollLeft: -newX, + scrollTop: -newY + }); + + // Trigger a scroll event + ionic.trigger(_this.scrollEventName, { + target: _this.el, + scrollLeft: -newX, + scrollTop: -newY + }); + }); + } + }, + + + + _handleEndDrag: function(e) { + // We didn't have a drag, so just init and leave + if(!this._drag) { + this._initDrag(); + return; + } + + // Set a flag in case we don't cleanup completely after the + // drag animation so we can cleanup the next time a drag starts + this._isStopped = true; + + // Animate to the finishing point + this._animateToStop(e); + + }, + + + // Find the stopping point given the current velocity and acceleration rate, and + // animate to that position + _animateToStop: function(e) { + var _this = this; + window.requestAnimationFrame(function() { + + var drag = _this._drag; + + // Calculate the viewport height and the height of the content + var totalWidth = _this.el.scrollWidth; + var totalHeight = _this.el.scrollHeight; + + // The parent bounding box helps us figure max/min scroll amounts + var parentWidth = _this.el.parentNode.offsetWidth; + var parentHeight = _this.el.parentNode.offsetHeight; + + // Calculate how long we've been dragging for, with a max of 300ms + var duration = Date.now() - _this._drag.startTime; + var time = 0; + var easing = ''; + + var newX = Math.round(_this.x); + var newY = Math.round(_this.y); + + _this.scrollTo(newX, newY); + + + // Check if we just snap back to bounds + if(_this.wrapScrollPosition(_this.bounceTime)) { + return; + } + + // If the duration is within reasonable bounds, enable momentum scrolling so we + // can "slide" to a finishing point + if(duration < 300) { + var momentumX = _this._getMomentum(_this.x, drag.startX, duration, parentWidth - totalWidth, parentWidth); + var momentumY = _this._getMomentum(_this.y, drag.startY, duration, parentHeight - totalHeight, parentHeight); + //var newX = momentumX.destination; + newX = momentumX.destination; + newY = momentumY.destination; + + // Calcualte the longest required time for the momentum animation and + // use that. + time = Math.max(momentumX.duration, momentumY.duration); + } + + // If we've moved, we will need to scroll + if(newX != _this.x || newY != _this.y) { + // If the end position is out of bounds, change the function we use for easing + // to get a different animation for the rubber banding + if ( newX > 0 || newX < (-totalWidth + parentWidth) || newY > 0 || newY < (-totalHeight + parentHeight)) { + easing = EASING_FUNCTIONS.bounce; + } + + _this.scrollTo(newX, newY, time, easing); + } + }); + } + }, { + DECEL_RATE_NORMAL: 0.998, + DECEL_RATE_FAST: 0.99, + DECEL_RATE_SLOW: 0.996, + }); + +})(ionic); +; +(function(ionic) { 'use strict'; /** * An ActionSheet is the slide up menu popularized on iOS. @@ -2724,14 +3322,9 @@ window.ionic = { */ ionic.views.ListView = ionic.views.Scroll.inherit({ initialize: function(opts) { - ionic.views.ListView.__super__.initialize.call(this, opts); - /* var _this = this; - this.el = opts.el; - - // The amount of dragging required to start sliding the element over (in pixels) - this.dragThresholdX = opts.dragThresholdX || 10; + ionic.views.ListView.__super__.initialize.call(this, opts); this.onRefresh = opts.onRefresh || function() {}; this.onRefreshOpening = opts.onRefreshOpening || function() {}; @@ -2741,6 +3334,7 @@ window.ionic = { this._initDrag(); // Listen for drag and release events + /* window.ionic.onGesture('drag', function(e) { _this._handleDrag(e); }, this.el); @@ -2759,7 +3353,24 @@ window.ionic = { }, didScroll: function(e) { - console.log('LIST VIEW SCROLLED', e); + console.log('Scrolling', Date.now()); + /* + if(this.isVirtual) { + var itemHeight = this.itemHeight; + var totalItems = this.el.children.length; + var scrollHeight = e.target.scrollHeight + var scrollTop = e.scrollTop; + var height = this.el.parentNode.offsetHeight; + console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height); + + var itemsPerPage = Math.floor(scrollHeight / itemHeight); + var first = parseInt(scrollTop / itemHeight) - totalItems; + console.log('FITS', itemsPerPage, 'per page, starting at', first); + + var nodes = Array.prototype.slice.call(this.el.children, first, itemsPerPage); + console.log('Showing these nodes:', nodes); + } + */ }, _initDrag: function() { @@ -2784,8 +3395,9 @@ window.ionic = { _startDrag: function(e) { ionic.views.ListView.__super__._startDrag.call(this, e); + return; + var _this = this; - /* this._isDragging = false; @@ -2798,9 +3410,7 @@ window.ionic = { this._dragOp.start(e); } } - */ - - /* + // Check if this is a "pull down" drag for pull to refresh else if(e.gesture.direction == 'down') { this._dragOp = new PullToRefreshDrag({ @@ -2817,23 +3427,20 @@ window.ionic = { }); this._dragOp.start(e); } - */ // Or check if this is a swipe to the side drag - /* else if(e.gesture.direction == 'left' || e.gesture.direction == 'right') { this._dragOp = new SlideDrag({ el: this.el }); this._dragOp.start(e); } - */ }, _handleEndDrag: function(e) { ionic.views.ListView.__super__._handleEndDrag.call(this, e); - /* var _this = this; + return; if(!this._dragOp) { this._initDrag(); return; @@ -2842,7 +3449,6 @@ window.ionic = { this._dragOp.end(e, function() { _this._initDrag(); }); - */ }, /** @@ -2850,16 +3456,15 @@ window.ionic = { */ _handleDrag: function(e) { ionic.views.ListView.__super__._handleDrag.call(this, e); - /* var _this = this, content, buttons; + return; if(!this._dragOp) { this._startDrag(e); if(!this._dragOp) { return; } } this._dragOp.drag(e); - */ } }); @@ -3021,558 +3626,6 @@ window.ionic = { } }; -})(ionic); -; -/** - * ionic.views.Scroll. Portions adapted from the great iScroll 5, which is - * also MIT licensed. - * iScroll v5.0.5 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license - * - * Think of ionic.views.Scroll like a Javascript version of UIScrollView or any - * scroll container in any UI library. You could just use -webkit-overflow-scrolling: touch, - * but you lose control over scroll behavior that native developers have with things - * like UIScrollView, and you don't get events after the finger stops touching the - * device (after a flick, for example). - * - * Some people are afraid of using Javascript powered scrolling, but - * with today's devices, Javascript is probably the best solution for - * scrolling in hybrid apps. - */ -(function(ionic) { -'use strict'; - var EASING_FUNCTIONS = { - quadratic: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', - circular: 'cubic-bezier(0.1, 0.57, 0.1, 1)', - circular2: 'cubic-bezier(0.075, 0.82, 0.165, 1)', - - bounce: 'cubic-bezier(.02,.69,.67,1)', - - // It closes like a high-end toilet seat. Fast, then nice and slow. - // Thanks to our @xtheglobe for that. - toiletSeat: 'cubic-bezier(0.05, 0.60, 0.05, 0.60)' - }; - - ionic.views.Scroll = ionic.views.View.inherit({ - initialize: function(opts) { - var _this = this; - - // Extend the options with our defaults - opts = ionic.Utils.extend({ - decelerationRate: ionic.views.Scroll.prototype.DECEL_RATE_NORMAL, - dragThreshold: 10, - resistance: 2, - scrollEventName: 'momentumScrolled', - scrollEndEventName: 'momentumScrollEnd', - intertialEventInterval: 50, - mouseWheelSpeed: 20, - invertWheel: false, - isVerticalEnabled: true, - isHorizontalEnabled: false, - bounceEasing: EASING_FUNCTIONS.bounce, - bounceTime: 600 //how long to take when bouncing back in a rubber band - }, opts); - - ionic.Utils.extend(this, opts); - - this.el = opts.el; - - this.y = 0; - this.x = 0; - - // Listen for drag and release events - ionic.onGesture('drag', function(e) { - _this._handleDrag(e); - }, this.el); - ionic.onGesture('release', function(e) { - _this._handleEndDrag(e); - }, this.el); - ionic.on('mousewheel', function(e) { - _this._wheel(e); - }, this.el); - ionic.on('DOMMouseScroll', function(e) { - _this._wheel(e); - }, this.el); - ionic.on(this.scrollEndEventName, function(e) { - _this._onScrollEnd(e); - }, this.el); - ionic.on('webkitTransitionEnd', function(e) { - _this._onTransitionEnd(e); - }); - }, - - /** - * Scroll to the given X and Y point, taking - * the given amount of time, with the given - * easing function defined as a CSS3 timing function. - * - * @param {float} the x position to scroll to (CURRENTLY NOT SUPPORTED!) - * @param {float} the y position to scroll to - * @param {float} the time to take scrolling to the new position - * @param {easing} the animation function to use for easing - */ - scrollTo: function(x, y, time, easing) { - var _this = this; - - - easing = easing || 'cubic-bezier(0.1, 0.57, 0.1, 1)'; - - var ox = x, oy = y; - - var el = this.el; - - if(x !== null) { - this.x = x; - } else { - x = this.x; - } - if(y !== null) { - this.y = y; - } else { - y = this.y; - } - - el.offsetHeight; - el.style.webkitTransitionTimingFunction = easing; - el.style.webkitTransitionDuration = time; - el.style.webkitTransform = 'translate3d(' + x + 'px,' + y + 'px, 0)'; - - // Start triggering events as the element scrolls from inertia. - // This is important because we need to receive scroll events - // even after a "flick" and adjust, etc. - this._momentumStepTimeout = setTimeout(function eventNotify() { - var trans = _this.el.style.webkitTransform.replace('translate3d(', '').split(','); - var scrollLeft = parseFloat(trans[0] || 0); - var scrollTop = parseFloat(trans[1] || 0); - - _this.didScroll && _this.didScroll({ - target: _this.el, - scrollLeft: -scrollLeft, - scrollTop: -scrollTop - }); - ionic.trigger(_this.scrollEventName, { - target: _this.el, - scrollLeft: -scrollLeft, - scrollTop: -scrollTop - }); - - if(_this._isDragging) { - _this._momentumStepTimeout = setTimeout(eventNotify, _this.inertialEventInterval); - } - }, this.inertialEventInterval) - }, - - /** - * If the scroll position is outside the current bounds, - * animate it back. - */ - wrapScrollPosition: function(transitionTime) { - var _this = this; - - var totalWidth = _this.el.scrollWidth; - var totalHeight = _this.el.scrollHeight; - var parentWidth = _this.el.parentNode.offsetWidth; - var parentHeight = _this.el.parentNode.offsetHeight; - - var maxX = Math.min(0, (-totalWidth + parentWidth)); - var maxY = Math.min(0, (-totalHeight + parentHeight)); - - //this._execEvent('scrollEnd'); - var x = _this.x, y = _this.y; - - if (!_this.isHorizontalEnabled || _this.x > 0) { - x = 0; - } else if ( _this.x < maxX) { - x = maxX; - } - - if (!_this.isVerticalEnabled || _this.y > 0) { - y = 0; - } else if (_this.y < maxY) { - y = maxY; - } - - // No change - if (x == _this.x && y == _this.y) { - return false; - } - _this.scrollTo(x, y, transitionTime || 0, _this.bounceEasing); - - return true; - }, - - _wheel: function(e) { - var wheelDeltaX, wheelDeltaY, - newX, newY, - that = this; - - var totalWidth = this.el.scrollWidth; - var totalHeight = this.el.scrollHeight; - var parentWidth = this.el.parentNode.offsetWidth; - var parentHeight = this.el.parentNode.offsetHeight; - - var maxX = Math.min(0, (-totalWidth + parentWidth)); - var maxY = Math.min(0, (-totalHeight + parentHeight)); - - // Execute the scrollEnd event after 400ms the wheel stopped scrolling - clearTimeout(this.wheelTimeout); - this.wheelTimeout = setTimeout(function () { - ionic.trigger(this.scrollEndEventName, { - target: this.el, - scrollLeft: this.x, - scrollTop: this.y - }); - }, 400); - - e.preventDefault(); - - if('wheelDeltaX' in e) { - wheelDeltaX = e.wheelDeltaX / 120; - wheelDeltaY = e.wheelDeltaY / 120; - } else if ('wheelDelta' in e) { - wheelDeltaX = wheelDeltaY = e.wheelDelta / 120; - } else if ('detail' in e) { - wheelDeltaX = wheelDeltaY = -e.detail / 3; - } else { - return; - } - - wheelDeltaX *= this.mouseWheelSpeed; - wheelDeltaY *= this.mouseWheelSpeed; - - if(!this.isVerticalEnabled) { - wheelDeltaX = wheelDeltaY; - wheelDeltaY = 0; - } - - newX = this.x + (this.isHorizontalEnabled ? wheelDeltaX * (this.invertWheel ? -1 : 1) : 0); - newY = this.y + (this.isVerticalEnabled ? wheelDeltaY * (this.invertWheel ? -1 : 1) : 0); - - if(newX > 0) { - newX = 0; - } else if (newX < maxX) { - newX = maxX; - } - - if(newY > 0) { - newY = 0; - } else if (newY < maxY) { - newY = maxY; - } - - this.scrollTo(newX, newY, 0); - }, - - _getMomentum: function (current, start, time, lowerMargin, wrapperSize) { - var distance = current - start, - speed = Math.abs(distance) / time, - destination, - duration, - deceleration = 0.0006; - - // Calculate the final desination - destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); - duration = speed / deceleration; - - // Check if the final destination needs to be rubber banded - if ( destination < lowerMargin ) { - // We have dragged too far down, snap back to the maximum - destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin; - distance = Math.abs(destination - current); - duration = distance / speed; - } else if ( destination > 0 ) { - - // We have dragged too far up, snap back to 0 - destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0; - distance = Math.abs(current) + destination; - duration = distance / speed; - } - - return { - destination: Math.round(destination), - duration: duration - }; - }, - - _onTransitionEnd: function(e) { - var _this = this; - - if (e.target != this.el) { - return; - } - - // Triggered to end scroll, once the final animation has ended - if(this._didEndScroll) { - this._didEndScroll = false; - ionic.trigger(_this.scrollEndEventName, { - target: _this.el, - scrollLeft: _this.x, - scrollTop: _this.y - }); - } - - this.el.style.webkitTransitionDuration = '0'; - - window.requestAnimationFrame(function() { - if(_this.wrapScrollPosition(_this.bounceTime)) { - _this._didEndScroll = true; - } - }); - }, - - _onScrollEnd: function() { - this._isDragging = false; - this._drag = null; - this.el.classList.remove('scroll-scrolling'); - - this.el.style.webkitTransitionDuration = '0'; - - clearTimeout(this._momentumStepTimeout) - }, - - - _initDrag: function() { - this._onScrollEnd(); - this._isStopped = false; - }, - - - /** - * Initialize a drag by grabbing the content area to drag, and any other - * info we might need for the dragging. - */ - _startDrag: function(e) { - var offsetX, content; - - this._initDrag(); - - var scrollLeft = parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[0]) || 0; - var scrollTop = parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[1]) || 0; - - var totalWidth = this.el.scrollWidth; - var totalHeight = this.el.scrollHeight; - var parentWidth = this.el.parentNode.offsetWidth; - var parentHeight = this.el.parentNode.offsetHeight; - - var maxX = Math.min(0, (-totalWidth + parentWidth)); - var maxY = Math.min(0, (-totalHeight + parentHeight)); - - // Check if we even have enough content to scroll, if not, don't start the drag - if((this.isHorizontalEnabled && maxX == 0) || (this.isVerticalEnabled && maxY == 0)) { - return; - } - - this.x = scrollLeft; - this.y = scrollTop; - - this._drag = { - direction: 'v', - pointX: e.gesture.touches[0].pageX, - pointY: e.gesture.touches[0].pageY, - startX: scrollLeft, - startY: scrollTop, - resist: 1, - startTime: Date.now() - }; - }, - - - - /** - * Process the drag event to move the item to the left or right. - * - * This function needs to be as fast as possible to make sure scrolling - * performance is high. - */ - _handleDrag: function(e) { - var _this = this; - - var content; - - // The drag stopped already, don't process this one - if(_this._isStopped) { - _this._initDrag(); - return; - } - - // We really aren't dragging - if(!_this._drag) { - _this._startDrag(e); - if(!_this._drag) { return; } - } - - // Stop any default events during the drag - e.preventDefault(); - - var px = e.gesture.touches[0].pageX; - var py = e.gesture.touches[0].pageY; - - var deltaX = px - _this._drag.pointX; - var deltaY = py - _this._drag.pointY; - - _this._drag.pointX = px; - _this._drag.pointY = py; - - // Check if we should start dragging. Check if we've dragged past the threshold. - if(!_this._isDragging && - ((Math.abs(e.gesture.deltaY) > _this.dragThreshold) || - (Math.abs(e.gesture.deltaX) > _this.dragThreshold))) { - _this._isDragging = true; - } - - if(_this._isDragging) { - var drag = _this._drag; - - // Request an animation frame to batch DOM reads/writes - window.requestAnimationFrame(function() { - // We are dragging, grab the current content height - - var totalWidth = _this.el.scrollWidth; - var totalHeight = _this.el.scrollHeight; - var parentWidth = _this.el.parentNode.offsetWidth; - var parentHeight = _this.el.parentNode.offsetHeight; - var maxX = Math.min(0, (-totalWidth + parentWidth)); - var maxY = Math.min(0, (-totalHeight + parentHeight)); - - // Grab current timestamp to keep our speend, etc. - // calculations in a window - var timestamp = Date.now(); - - // Calculate the new Y point for the container - // TODO: Only enable certain axes - var newX = _this.x + deltaX; - var newY = _this.y + deltaY; - - if(newX > 0 || (-newX + parentWidth) > totalWidth) { - // Rubber band - newX = _this.x + deltaX / 3; - } - // Check if the dragging is beyond the bottom or top - if(newY > 0 || (-newY + parentHeight) > totalHeight) { - // Rubber band - newY = _this.y + deltaY / 3;//(-_this.resistance); - } - - if(!_this.isHorizontalEnabled) { - newX = 0; - } - if(!_this.isVerticalEnabled) { - newY = 0; - } - - // Update the new translated Y point of the container - _this.el.style.webkitTransform = 'translate3d(' + newX + 'px,' + newY + 'px, 0)'; - - // Store the last points - _this.x = newX; - _this.y = newY; - - // Check if we need to reset the drag initial states if we've - // been dragging for a bit - if(timestamp - drag.startTime > 300) { - drag.startTime = timestamp; - drag.startX = _this.x; - drag.startY = _this.y; - } - - _this.didScroll && _this.didScroll({ - target: _this.el, - scrollLeft: -newX, - scrollTop: -newY - }); - - // Trigger a scroll event - ionic.trigger(_this.scrollEventName, { - target: _this.el, - scrollLeft: -newX, - scrollTop: -newY - }); - }); - } - }, - - - - _handleEndDrag: function(e) { - // We didn't have a drag, so just init and leave - if(!this._drag) { - this._initDrag(); - return; - } - - // Set a flag in case we don't cleanup completely after the - // drag animation so we can cleanup the next time a drag starts - this._isStopped = true; - - // Animate to the finishing point - this._animateToStop(e); - - }, - - - // Find the stopping point given the current velocity and acceleration rate, and - // animate to that position - _animateToStop: function(e) { - var _this = this; - window.requestAnimationFrame(function() { - - var drag = _this._drag; - - // Calculate the viewport height and the height of the content - var totalWidth = _this.el.scrollWidth; - var totalHeight = _this.el.scrollHeight; - - // The parent bounding box helps us figure max/min scroll amounts - var parentWidth = _this.el.parentNode.offsetWidth; - var parentHeight = _this.el.parentNode.offsetHeight; - - // Calculate how long we've been dragging for, with a max of 300ms - var duration = Date.now() - _this._drag.startTime; - var time = 0; - var easing = ''; - - var newX = Math.round(_this.x); - var newY = Math.round(_this.y); - - _this.scrollTo(newX, newY); - - - // Check if we just snap back to bounds - if(_this.wrapScrollPosition(_this.bounceTime)) { - return; - } - - // If the duration is within reasonable bounds, enable momentum scrolling so we - // can "slide" to a finishing point - if(duration < 300) { - var momentumX = _this._getMomentum(_this.x, drag.startX, duration, parentWidth - totalWidth, parentWidth); - var momentumY = _this._getMomentum(_this.y, drag.startY, duration, parentHeight - totalHeight, parentHeight); - //var newX = momentumX.destination; - newX = momentumX.destination; - newY = momentumY.destination; - - // Calcualte the longest required time for the momentum animation and - // use that. - time = Math.max(momentumX.duration, momentumY.duration); - } - - // If we've moved, we will need to scroll - if(newX != _this.x || newY != _this.y) { - // If the end position is out of bounds, change the function we use for easing - // to get a different animation for the rubber banding - if ( newX > 0 || newX < (-totalWidth + parentWidth) || newY > 0 || newY < (-totalHeight + parentHeight)) { - easing = EASING_FUNCTIONS.bounce; - } - - _this.scrollTo(newX, newY, time, easing); - } - }); - } - }, { - DECEL_RATE_NORMAL: 0.998, - DECEL_RATE_FAST: 0.99, - DECEL_RATE_SLOW: 0.996, - }); - })(ionic); ; (function(ionic) { @@ -4200,20 +4253,6 @@ ionic.views.TabBar.prototype = { })(ionic); ; (function(ionic) { -'use strict'; - ionic.views.View = function() { - this.initialize.apply(this, arguments); - }; - - ionic.views.View.inherit = ionic.inherit; - - ionic.extend(ionic.views.View.prototype, { - initialize: function() {} - }); - -})(window.ionic); -; -(function(ionic) { 'use strict'; /** diff --git a/js/views/listViewScroll.js b/js/views/listViewScroll.js index 3dc9b2170f..5623f48a08 100644 --- a/js/views/listViewScroll.js +++ b/js/views/listViewScroll.js @@ -362,14 +362,9 @@ */ ionic.views.ListView = ionic.views.Scroll.inherit({ initialize: function(opts) { - ionic.views.ListView.__super__.initialize.call(this, opts); - /* var _this = this; - this.el = opts.el; - - // The amount of dragging required to start sliding the element over (in pixels) - this.dragThresholdX = opts.dragThresholdX || 10; + ionic.views.ListView.__super__.initialize.call(this, opts); this.onRefresh = opts.onRefresh || function() {}; this.onRefreshOpening = opts.onRefreshOpening || function() {}; @@ -379,6 +374,7 @@ this._initDrag(); // Listen for drag and release events + /* window.ionic.onGesture('drag', function(e) { _this._handleDrag(e); }, this.el); @@ -397,7 +393,24 @@ }, didScroll: function(e) { - console.log('LIST VIEW SCROLLED', e); + console.log('Scrolling', Date.now()); + /* + if(this.isVirtual) { + var itemHeight = this.itemHeight; + var totalItems = this.el.children.length; + var scrollHeight = e.target.scrollHeight + var scrollTop = e.scrollTop; + var height = this.el.parentNode.offsetHeight; + console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height); + + var itemsPerPage = Math.floor(scrollHeight / itemHeight); + var first = parseInt(scrollTop / itemHeight) - totalItems; + console.log('FITS', itemsPerPage, 'per page, starting at', first); + + var nodes = Array.prototype.slice.call(this.el.children, first, itemsPerPage); + console.log('Showing these nodes:', nodes); + } + */ }, _initDrag: function() { @@ -422,8 +435,9 @@ _startDrag: function(e) { ionic.views.ListView.__super__._startDrag.call(this, e); + return; + var _this = this; - /* this._isDragging = false; @@ -436,9 +450,7 @@ this._dragOp.start(e); } } - */ - - /* + // Check if this is a "pull down" drag for pull to refresh else if(e.gesture.direction == 'down') { this._dragOp = new PullToRefreshDrag({ @@ -455,23 +467,20 @@ }); this._dragOp.start(e); } - */ // Or check if this is a swipe to the side drag - /* else if(e.gesture.direction == 'left' || e.gesture.direction == 'right') { this._dragOp = new SlideDrag({ el: this.el }); this._dragOp.start(e); } - */ }, _handleEndDrag: function(e) { ionic.views.ListView.__super__._handleEndDrag.call(this, e); - /* var _this = this; + return; if(!this._dragOp) { this._initDrag(); return; @@ -480,7 +489,6 @@ this._dragOp.end(e, function() { _this._initDrag(); }); - */ }, /** @@ -488,16 +496,15 @@ */ _handleDrag: function(e) { ionic.views.ListView.__super__._handleDrag.call(this, e); - /* var _this = this, content, buttons; + return; if(!this._dragOp) { this._startDrag(e); if(!this._dragOp) { return; } } this._dragOp.drag(e); - */ } }); diff --git a/js/views/scrollView.js b/js/views/scrollView.js index 91fdf9ec67..dcbd4b3563 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -38,7 +38,7 @@ resistance: 2, scrollEventName: 'momentumScrolled', scrollEndEventName: 'momentumScrollEnd', - intertialEventInterval: 50, + inertialEventInterval: 50, mouseWheelSpeed: 20, invertWheel: false, isVerticalEnabled: true, @@ -47,7 +47,7 @@ bounceTime: 600 //how long to take when bouncing back in a rubber band }, opts); - ionic.Utils.extend(this, opts); + ionic.extend(this, opts); this.el = opts.el; @@ -111,6 +111,7 @@ el.style.webkitTransitionDuration = time; el.style.webkitTransform = 'translate3d(' + x + 'px,' + y + 'px, 0)'; + clearTimeout(this._momentumStepTimeout); // Start triggering events as the element scrolls from inertia. // This is important because we need to receive scroll events // even after a "flick" and adjust, etc. @@ -136,6 +137,28 @@ }, this.inertialEventInterval) }, + needsWrapping: function() { + var _this = this; + + var totalWidth = this.el.scrollWidth; + var totalHeight = this.el.scrollHeight; + var parentWidth = this.el.parentNode.offsetWidth; + var parentHeight = this.el.parentNode.offsetHeight; + + var maxX = Math.min(0, (-totalWidth + parentWidth)); + var maxY = Math.min(0, (-totalHeight + parentHeight)); + + if (this.isHorizontalEnabled && (this.x > 0 || this.x < maxX)) { + return true; + } + + if (this.isVerticalEnabled && (this.y > 0 || this.y < maxY)) { + return true; + } + + return false; + }, + /** * If the scroll position is outside the current bounds, * animate it back. @@ -275,13 +298,22 @@ return; } + var needsWrapping = this.needsWrapping(); + // Triggered to end scroll, once the final animation has ended - if(this._didEndScroll) { + if(needsWrapping && this._didEndScroll) { this._didEndScroll = false; - ionic.trigger(_this.scrollEndEventName, { - target: _this.el, - scrollLeft: _this.x, - scrollTop: _this.y + ionic.trigger(this.scrollEndEventName, { + target: this.el, + scrollLeft: this.x, + scrollTop: this.y + }); + } else if(!needsWrapping) { + this._didEndScroll = false; + ionic.trigger(this.scrollEndEventName, { + target: this.el, + scrollLeft: this.x, + scrollTop: this.y }); } diff --git a/test/biglists.html b/test/biglists.html new file mode 100644 index 0000000000..4bd24a14fe --- /dev/null +++ b/test/biglists.html @@ -0,0 +1,1288 @@ + + + + Lists + + + + + + + + +
+

Lists

+
+ +
+ +
+ +
+ Work +
+ + + + Check mail + + + + + Call Ma + + +
+ Work +
+ + + + Check mail + 5 + + + + + Call Ma + + Cell + + + + + + Record album + + Grammy + + + + + + Breaking Bad + + Blue, yellow, pink + + + +
+ Leisure +
+ + + + Games + + Super Mario + + + + + + Music + + JT + + + + + + Shopping + + Bag + + + + + + Friends + 0 + + + +
+ List Header +
+ +
+ Not a link so no default right arrow +
+ + +
+ Auto Right side arrow cuz its a link +
+
+ + +
+ Processing Icon + +
+
+ +
+ List Divider +
+ + +
+ Computers + Badge +
+
+ +
+
+ + +
+ Monitors + 6 +
+
+ +
+
+ + +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ Multiple Badges + 62 + 4 + 143 +
+
+ +
+
+ +
+ +
+ Homepage +
+ +
+ + + + + + + + diff --git a/test/lists.html b/test/lists.html index ec0f9f6d6a..2e568f389c 100644 --- a/test/lists.html +++ b/test/lists.html @@ -450,7 +450,6 @@ -