@@ -509,12 +509,12 @@ angular.module('ionic.ui.header', ['ngAnimate'])
509
509
transclude : true ,
510
510
template : '<header class="bar bar-header">\
511
511
<div class="buttons">\
512
- <button ng-repeat="button in leftButtons" class="button" ng-class="button.type" ng-click="button.tap($event, $index)" ng-bind-html="button.content">\
512
+ <button ng-repeat="button in leftButtons" class="button no-animation " ng-class="button.type" ng-click="button.tap($event, $index)" ng-bind-html="button.content">\
513
513
</button>\
514
514
</div>\
515
515
<h1 class="title" ng-bind-html="title"></h1>\
516
516
<div class="buttons">\
517
- <button ng-repeat="button in rightButtons" class="button" ng-class="button.type" ng-click="button.tap($event, $index)" ng-bind-html="button.content">\
517
+ <button ng-repeat="button in rightButtons" class="button no-animation " ng-class="button.type" ng-click="button.tap($event, $index)" ng-bind-html="button.content">\
518
518
</button>\
519
519
</div>\
520
520
</header>' ,
@@ -543,6 +543,7 @@ angular.module('ionic.ui.header', ['ngAnimate'])
543
543
} ) ;
544
544
545
545
$scope . $watch ( 'rightButtons' , function ( val ) {
546
+ console . log ( 'Right buttons changed' ) ;
546
547
// Resize the title since the buttons have changed
547
548
hb . align ( ) ;
548
549
} ) ;
@@ -1516,6 +1517,7 @@ angular.module('ionic.ui.scroll', [])
1516
1517
transclude : true ,
1517
1518
scope : {
1518
1519
direction : '@' ,
1520
+ paging : '@' ,
1519
1521
onRefresh : '&' ,
1520
1522
onScroll : '&' ,
1521
1523
refreshComplete : '=' ,
@@ -1524,46 +1526,51 @@ angular.module('ionic.ui.scroll', [])
1524
1526
scrollbarY : '@' ,
1525
1527
} ,
1526
1528
1529
+ controller : function ( ) { } ,
1530
+
1527
1531
compile : function ( element , attr , transclude ) {
1528
1532
return function ( $scope , $element , $attr ) {
1529
1533
var clone , sv , sc = document . createElement ( 'div' ) ;
1530
1534
1535
+ // Create the internal scroll div
1531
1536
sc . className = 'scroll' ;
1532
1537
if ( attr . padding == "true" ) {
1533
- sc . className += ' padding';
1538
+ sc . classList . add ( ' padding') ;
1534
1539
addedPadding = true ;
1535
1540
}
1541
+ if ( $scope . $eval ( $scope . paging ) === true ) {
1542
+ sc . classList . add ( 'scroll-paging' ) ;
1543
+ }
1536
1544
$element . append ( sc ) ;
1537
1545
1538
1546
// Pass the parent scope down to the child
1539
1547
clone = transclude ( $scope . $parent ) ;
1540
1548
angular . element ( $element [ 0 ] . firstElementChild ) . append ( clone ) ;
1541
1549
1550
+ // Get refresher size
1542
1551
var refresher = $element [ 0 ] . querySelector ( '.scroll-refresher' ) ;
1543
1552
var refresherHeight = refresher && refresher . clientHeight || 0 ;
1544
1553
1545
- if ( attr . refreshComplete ) {
1546
- $scope . refreshComplete = function ( ) {
1547
- if ( $scope . scrollView ) {
1548
- refresher && refresher . classList . remove ( 'active' ) ;
1549
- $scope . scrollView . finishPullToRefresh ( ) ;
1550
- $scope . $parent . $broadcast ( 'scroll.onRefreshComplete' ) ;
1551
- }
1552
- } ;
1553
- }
1554
-
1555
-
1554
+ if ( ! $scope . direction ) { $scope . direction = 'y' ; }
1556
1555
var hasScrollingX = $scope . direction . indexOf ( 'x' ) >= 0 ;
1557
1556
var hasScrollingY = $scope . direction . indexOf ( 'y' ) >= 0 ;
1558
1557
1559
1558
$timeout ( function ( ) {
1560
- sv = new ionic . views . Scroll ( {
1559
+ var options = {
1561
1560
el : $element [ 0 ] ,
1561
+ paging : $scope . $eval ( $scope . paging ) === true ,
1562
1562
scrollbarX : $scope . $eval ( $scope . scrollbarX ) !== false ,
1563
1563
scrollbarY : $scope . $eval ( $scope . scrollbarY ) !== false ,
1564
1564
scrollingX : hasScrollingX ,
1565
1565
scrollingY : hasScrollingY
1566
- } ) ;
1566
+ } ;
1567
+
1568
+ if ( options . paging ) {
1569
+ options . speedMultiplier = 0.8 ;
1570
+ options . bouncing = false ;
1571
+ }
1572
+
1573
+ sv = new ionic . views . Scroll ( options ) ;
1567
1574
1568
1575
// Activate pull-to-refresh
1569
1576
if ( refresher ) {
@@ -1807,41 +1814,68 @@ angular.module('ionic.ui.slideBox', [])
1807
1814
* some side menu stuff on the current scope.
1808
1815
*/
1809
1816
1810
- . directive ( 'slideBox' , [ '$compile' , function ( $compile ) {
1817
+ . directive ( 'slideBox' , [ '$timeout' , '$ compile', function ( $timeout , $compile ) {
1811
1818
return {
1812
1819
restrict : 'E' ,
1813
1820
replace : true ,
1814
1821
transclude : true ,
1815
- scope : { } ,
1822
+ scope : {
1823
+ doesContinue : '@' ,
1824
+ showPager : '@' ,
1825
+ onSlideChanged : '&'
1826
+ } ,
1816
1827
controller : [ '$scope' , '$element' , function ( $scope , $element ) {
1817
- $scope . slides = [ ] ;
1818
- this . slideAdded = function ( ) {
1819
- $scope . slides . push ( { } ) ;
1820
- } ;
1821
-
1822
- angular . extend ( this , ionic . views . SlideBox . prototype ) ;
1828
+ var _this = this ;
1823
1829
1824
- ionic . views . SlideBox . call ( this , {
1830
+ var slider = new ionic . views . Slider ( {
1825
1831
el : $element [ 0 ] ,
1826
- slideChanged : function ( slideIndex ) {
1832
+ continuous : $scope . $eval ( $scope . doesContinue ) === true ,
1833
+ slidesChanged : function ( ) {
1834
+ $scope . currentSlide = slider . getPos ( ) ;
1835
+
1836
+ // Try to trigger a digest
1837
+ $timeout ( function ( ) { } ) ;
1838
+ } ,
1839
+ callback : function ( slideIndex ) {
1840
+ $scope . currentSlide = slideIndex ;
1841
+ $scope . onSlideChanged ( { index :$scope . currentSlide } ) ;
1827
1842
$scope . $parent . $broadcast ( 'slideBox.slideChanged' , slideIndex ) ;
1828
- $scope . $apply ( ) ;
1843
+
1844
+ // Try to trigger a digest
1845
+ $timeout ( function ( ) { } ) ;
1829
1846
}
1830
1847
} ) ;
1831
1848
1832
- $scope . $parent . slideBox = this ;
1849
+ $scope . $on ( 'slideBox.nextSlide' , function ( ) {
1850
+ slider . next ( ) ;
1851
+ } ) ;
1852
+
1853
+ $scope . $on ( 'slideBox.prevSlide' , function ( ) {
1854
+ slider . prev ( ) ;
1855
+ } ) ;
1856
+
1857
+ $scope . $on ( 'slideBox.setSlide' , function ( e , index ) {
1858
+ slider . slide ( index ) ;
1859
+ } ) ;
1860
+
1861
+ $scope . slideBox = slider ;
1862
+
1863
+ $timeout ( function ( ) {
1864
+ slider . load ( ) ;
1865
+ } ) ;
1833
1866
} ] ,
1834
- template : '<div class="slide-box ">\
1835
- <div class="slide-box -slides" ng-transclude>\
1867
+ template : '<div class="slider ">\
1868
+ <div class="slider -slides" ng-transclude>\
1836
1869
</div>\
1837
1870
</div>' ,
1838
1871
1839
1872
link : function ( $scope , $element , $attr , slideBoxCtrl ) {
1840
1873
// If the pager should show, append it to the slide box
1841
- if ( $attr . showPager !== " false" ) {
1874
+ if ( $scope . $eval ( $scope . showPager ) !== false ) {
1842
1875
var childScope = $scope . $new ( ) ;
1843
- var pager = $compile ( '<pager></pager>' ) ( childScope ) ;
1876
+ var pager = angular . element ( '<pager></pager>' ) ;
1844
1877
$element . append ( pager ) ;
1878
+ $compile ( pager ) ( childScope ) ;
1845
1879
}
1846
1880
}
1847
1881
} ;
@@ -1853,10 +1887,9 @@ angular.module('ionic.ui.slideBox', [])
1853
1887
replace : true ,
1854
1888
require : '^slideBox' ,
1855
1889
transclude : true ,
1856
- template : '<div class="slide-box -slide" ng-transclude></div>' ,
1890
+ template : '<div class="slider -slide" ng-transclude></div>' ,
1857
1891
compile : function ( element , attr , transclude ) {
1858
1892
return function ( $scope , $element , $attr , slideBoxCtrl ) {
1859
- slideBoxCtrl . slideAdded ( ) ;
1860
1893
} ;
1861
1894
}
1862
1895
} ;
@@ -1867,7 +1900,29 @@ angular.module('ionic.ui.slideBox', [])
1867
1900
restrict : 'E' ,
1868
1901
replace : true ,
1869
1902
require : '^slideBox' ,
1870
- template : '<div class="slide-box-pager"><span ng-repeat="slide in slides"><i class="icon ion-record"></i></span></div>'
1903
+ template : '<div class="slider-pager"><span class="slider-pager-page" ng-repeat="slide in numSlides() track by $index" ng-class="{active: $index == currentSlide}"><i class="icon ion-record"></i></span></div>' ,
1904
+ link : function ( $scope , $element , $attr , slideBox ) {
1905
+ var selectPage = function ( index ) {
1906
+ var children = $element [ 0 ] . children ;
1907
+ var length = children . length ;
1908
+ for ( var i = 0 ; i < length ; i ++ ) {
1909
+ if ( i == index ) {
1910
+ children [ i ] . classList . add ( 'active' ) ;
1911
+ } else {
1912
+ children [ i ] . classList . remove ( 'active' ) ;
1913
+ }
1914
+ }
1915
+ } ;
1916
+
1917
+ $scope . numSlides = function ( ) {
1918
+ return new Array ( $scope . slideBox . getNumSlides ( ) ) ;
1919
+ } ;
1920
+
1921
+ $scope . $watch ( 'currentSlide' , function ( v ) {
1922
+ console . log ( 'Current slide' , v ) ;
1923
+ selectPage ( v ) ;
1924
+ } ) ;
1925
+ }
1871
1926
} ;
1872
1927
1873
1928
} ) ;
0 commit comments