22 * Copyright 2014 Drifty Co.
33 * http://drifty.com/
44 *
5- * Ionic, v1.0.0-rc.1
5+ * Ionic, v1.0.0-rc.2
66 * A powerful HTML5 mobile app framework.
77 * http://ionicframework.com/
88 *
@@ -2944,8 +2944,9 @@ function($ionicModal, $ionicPosition, $document, $window) {
29442944 var buttonOffset = $ionicPosition . offset ( targetEle ) ;
29452945 var popoverWidth = popoverEle . prop ( 'offsetWidth' ) ;
29462946 var popoverHeight = popoverEle . prop ( 'offsetHeight' ) ;
2947- var bodyWidth = $document [ 0 ] . body . clientWidth ;
2948- // clientHeight doesn't work on all platforms for body
2947+ // Use innerWidth and innerHeight, because clientWidth and clientHeight
2948+ // doesn't work consistently for body on all platforms
2949+ var bodyWidth = $window . innerWidth ;
29492950 var bodyHeight = $window . innerHeight ;
29502951
29512952 var popoverCSS = {
@@ -6674,8 +6675,8 @@ IonicModule
66746675 scrollParent = $element . parent ( ) . parent ( ) [ 0 ] ;
66756676 scrollChild = $element . parent ( ) [ 0 ] ;
66766677
6677- if ( ! scrollParent . classList . contains ( 'ionic-scroll' ) ||
6678- ! scrollChild . classList . contains ( 'scroll' ) ) {
6678+ if ( ! scrollParent || ! scrollParent . classList . contains ( 'ionic-scroll' ) ||
6679+ ! scrollChild || ! scrollChild . classList . contains ( 'scroll' ) ) {
66796680 throw new Error ( 'Refresher must be immediate child of ion-content or ion-scroll' ) ;
66806681 }
66816682
@@ -6778,10 +6779,19 @@ function($scope,
67786779 self . __timeout = $timeout ;
67796780
67806781 self . _scrollViewOptions = scrollViewOptions ; //for testing
6782+ self . isNative = function ( ) {
6783+ return ! ! scrollViewOptions . nativeScrolling ;
6784+ } ;
67816785
67826786 var element = self . element = scrollViewOptions . el ;
67836787 var $element = self . $element = jqLite ( element ) ;
6784- var scrollView = self . scrollView = new ionic . views . Scroll ( scrollViewOptions ) ;
6788+ var scrollView ;
6789+ if ( self . isNative ( ) ) {
6790+ scrollView = self . scrollView = new ionic . views . ScrollNative ( scrollViewOptions ) ;
6791+ } else {
6792+ scrollView = self . scrollView = new ionic . views . Scroll ( scrollViewOptions ) ;
6793+ }
6794+
67856795
67866796 //Attach self to element as a controller so other directives can require this controller
67876797 //through `require: '$ionicScroll'
@@ -9279,37 +9289,55 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
92799289
92809290 if ( $attr . scroll === "false" ) {
92819291 //do nothing
9282- } else if ( attr . overflowScroll === "true" || ! $ionicConfig . scrolling . jsScrolling ( ) ) {
9283- // use native scrolling
9284- $element . addClass ( 'overflow-scroll' ) ;
92859292 } else {
9286- var scrollViewOptions = {
9287- el : $element [ 0 ] ,
9288- delegateHandle : attr . delegateHandle ,
9289- locking : ( attr . locking || 'true' ) === 'true' ,
9290- bouncing : $scope . $eval ( $scope . hasBouncing ) ,
9291- startX : $scope . $eval ( $scope . startX ) || 0 ,
9292- startY : $scope . $eval ( $scope . startY ) || 0 ,
9293- scrollbarX : $scope . $eval ( $scope . scrollbarX ) !== false ,
9294- scrollbarY : $scope . $eval ( $scope . scrollbarY ) !== false ,
9295- scrollingX : $scope . direction . indexOf ( 'x' ) >= 0 ,
9296- scrollingY : $scope . direction . indexOf ( 'y' ) >= 0 ,
9297- scrollEventInterval : parseInt ( $scope . scrollEventInterval , 10 ) || 10 ,
9298- scrollingComplete : function ( ) {
9299- $scope . $onScrollComplete ( {
9300- scrollTop : this . __scrollTop ,
9301- scrollLeft : this . __scrollLeft
9302- } ) ;
9303- }
9304- } ;
9293+ var scrollViewOptions = { } ;
9294+
9295+ if ( attr . overflowScroll === "true" || ! $ionicConfig . scrolling . jsScrolling ( ) ) {
9296+ // use native scrolling
9297+ $element . addClass ( 'overflow-scroll' ) ;
9298+
9299+ scrollViewOptions = {
9300+ el : $element [ 0 ] ,
9301+ delegateHandle : attr . delegateHandle ,
9302+ startX : $scope . $eval ( $scope . startX ) || 0 ,
9303+ startY : $scope . $eval ( $scope . startY ) || 0 ,
9304+ nativeScrolling :true
9305+ } ;
9306+
9307+ } else {
9308+ // Use JS scrolling
9309+ scrollViewOptions = {
9310+ el : $element [ 0 ] ,
9311+ delegateHandle : attr . delegateHandle ,
9312+ locking : ( attr . locking || 'true' ) === 'true' ,
9313+ bouncing : $scope . $eval ( $scope . hasBouncing ) ,
9314+ startX : $scope . $eval ( $scope . startX ) || 0 ,
9315+ startY : $scope . $eval ( $scope . startY ) || 0 ,
9316+ scrollbarX : $scope . $eval ( $scope . scrollbarX ) !== false ,
9317+ scrollbarY : $scope . $eval ( $scope . scrollbarY ) !== false ,
9318+ scrollingX : $scope . direction . indexOf ( 'x' ) >= 0 ,
9319+ scrollingY : $scope . direction . indexOf ( 'y' ) >= 0 ,
9320+ scrollEventInterval : parseInt ( $scope . scrollEventInterval , 10 ) || 10 ,
9321+ scrollingComplete : function ( ) {
9322+ $scope . $onScrollComplete ( {
9323+ scrollTop : this . __scrollTop ,
9324+ scrollLeft : this . __scrollLeft
9325+ } ) ;
9326+ }
9327+ } ;
9328+ }
9329+
9330+ // init scroll controller with appropriate options
93059331 $controller ( '$ionicScroll' , {
93069332 $scope : $scope ,
93079333 scrollViewOptions : scrollViewOptions
93089334 } ) ;
93099335
93109336 $scope . $on ( '$destroy' , function ( ) {
9311- scrollViewOptions . scrollingComplete = noop ;
9312- delete scrollViewOptions . el ;
9337+ if ( scrollViewOptions ) {
9338+ scrollViewOptions . scrollingComplete = noop ;
9339+ delete scrollViewOptions . el ;
9340+ }
93139341 innerElement = null ;
93149342 $element = null ;
93159343 attr . $$element = null ;
@@ -9926,10 +9954,14 @@ IonicModule
99269954 link : function ( $scope , $element , $attrs , ctrls ) {
99279955 var infiniteScrollCtrl = ctrls [ 1 ] ;
99289956 var scrollCtrl = infiniteScrollCtrl . scrollCtrl = ctrls [ 0 ] ;
9929- var jsScrolling = infiniteScrollCtrl . jsScrolling = ! ! scrollCtrl ;
9957+ var jsScrolling = infiniteScrollCtrl . jsScrolling = ! scrollCtrl . isNative ( ) ;
9958+
99309959 // if this view is not beneath a scrollCtrl, it can't be injected, proceed w/ native scrolling
99319960 if ( jsScrolling ) {
99329961 infiniteScrollCtrl . scrollView = scrollCtrl . scrollView ;
9962+ $scope . scrollingType = 'js-scrolling' ;
9963+ //bind to JS scroll events
9964+ scrollCtrl . $element . on ( 'scroll' , infiniteScrollCtrl . checkBounds ) ;
99339965 } else {
99349966 // grabbing the scrollable element, to determine dimensions, and current scroll pos
99359967 var scrollEl = ionic . DomUtil . getParentOrSelfWithClass ( $element [ 0 ] . parentNode , 'overflow-scroll' ) ;
@@ -9938,14 +9970,10 @@ IonicModule
99389970 if ( ! scrollEl ) {
99399971 throw 'Infinite scroll must be used inside a scrollable div' ;
99409972 }
9941- }
9942- //bind to appropriate scroll event
9943- if ( jsScrolling ) {
9944- $scope . scrollingType = 'js-scrolling' ;
9945- scrollCtrl . $element . on ( 'scroll' , infiniteScrollCtrl . checkBounds ) ;
9946- } else {
9973+ //bind to native scroll events
99479974 infiniteScrollCtrl . scrollEl . addEventListener ( 'scroll' , infiniteScrollCtrl . checkBounds ) ;
99489975 }
9976+
99499977 // Optionally check bounds on start after scrollView is fully rendered
99509978 var doImmediateCheck = isDefined ( $attrs . immediateCheck ) ? $scope . $eval ( $attrs . immediateCheck ) : true ;
99519979 if ( doImmediateCheck ) {
@@ -11524,6 +11552,7 @@ IonicModule
1152411552 * of the refresher.
1152511553 * @param {expression= } on-pulling Called when the user starts to pull down
1152611554 * on the refresher.
11555+ * @param {string= } pulling-text The text to display while the user is pulling down.
1152711556 * @param {string= } pulling-icon The icon to display while the user is pulling down.
1152811557 * Default: 'ion-android-arrow-down'.
1152911558 * @param {string= } spinner The {@link ionic.directive:ionSpinner} icon to display
@@ -11563,10 +11592,11 @@ IonicModule
1156311592 // JS Scrolling uses the scroll controller
1156411593 var scrollCtrl = ctrls [ 0 ] ,
1156511594 refresherCtrl = ctrls [ 1 ] ;
11566-
11567- if ( ! ! scrollCtrl ) {
11595+ if ( ! scrollCtrl || scrollCtrl . isNative ( ) ) {
11596+ // Kick off native scrolling
11597+ refresherCtrl . init ( ) ;
11598+ } else {
1156811599 $element [ 0 ] . classList . add ( 'js-scrolling' ) ;
11569-
1157011600 scrollCtrl . _setRefresher (
1157111601 $scope ,
1157211602 $element [ 0 ] ,
@@ -11578,10 +11608,6 @@ IonicModule
1157811608 scrollCtrl . scrollView . finishPullToRefresh ( ) ;
1157911609 } ) ;
1158011610 } ) ;
11581-
11582- } else {
11583- // Kick off native scrolling
11584- refresherCtrl . init ( ) ;
1158511611 }
1158611612
1158711613 }
@@ -11951,6 +11977,9 @@ function($timeout, $ionicGesture, $window) {
1195111977
1195211978 // add gesture handlers
1195311979 var gestureOpts = { stop_browser_behavior : false } ;
11980+ if ( ionic . DomUtil . getParentOrSelfWithClass ( $element [ 0 ] , 'overflow-scroll' ) ) {
11981+ gestureOpts . prevent_default_directions = [ 'left' , 'right' ] ;
11982+ }
1195411983 var contentTapGesture = $ionicGesture . on ( 'tap' , onContentTap , $element , gestureOpts ) ;
1195511984 var dragRightGesture = $ionicGesture . on ( 'dragright' , onDragX , $element , gestureOpts ) ;
1195611985 var dragLeftGesture = $ionicGesture . on ( 'dragleft' , onDragX , $element , gestureOpts ) ;
0 commit comments