@@ -7,12 +7,12 @@ import { Img } from '../img/img';
7
7
import { Ion } from '../ion' ;
8
8
import { isTrueProperty , assert , removeArrayItem } from '../../util/util' ;
9
9
import { Keyboard } from '../../util/keyboard' ;
10
- import { ScrollView , ScrollDirection , ScrollEvent } from '../../util/scroll-view' ;
10
+ import { ScrollView , ScrollEvent } from '../../util/scroll-view' ;
11
11
import { Tabs } from '../tabs/tabs' ;
12
12
import { transitionEnd } from '../../util/dom' ;
13
13
import { ViewController } from '../../navigation/view-controller' ;
14
14
15
- export { ScrollEvent , ScrollDirection } from '../../util/scroll-view' ;
15
+ export { ScrollEvent } from '../../util/scroll-view' ;
16
16
17
17
18
18
/**
@@ -242,7 +242,7 @@ export class Content extends Ion implements OnDestroy, OnInit {
242
242
* @return {number }
243
243
*/
244
244
get velocityY ( ) : number {
245
- return this . _scroll . ev . velocityY || 0 ;
245
+ return this . _scroll . ev . velocityY ;
246
246
}
247
247
248
248
/**
@@ -251,24 +251,24 @@ export class Content extends Ion implements OnDestroy, OnInit {
251
251
* @return {number }
252
252
*/
253
253
get velocityX ( ) : number {
254
- return this . _scroll . ev . velocityX || 0 ;
254
+ return this . _scroll . ev . velocityX ;
255
255
}
256
256
257
257
/**
258
258
* The current, or last known, vertical scroll direction.
259
259
*
260
- * @return {ScrollDirection }
260
+ * @return {string }
261
261
*/
262
- get directionY ( ) : ScrollDirection {
262
+ get directionY ( ) : string {
263
263
return this . _scroll . ev . directionY ;
264
264
}
265
265
266
266
/**
267
267
* The current, or last known, horizontal scroll direction.
268
268
*
269
- * @return {ScrollDirection }
269
+ * @return {string }
270
270
*/
271
- get directionX ( ) : ScrollDirection {
271
+ get directionX ( ) : string {
272
272
return this . _scroll . ev . directionX ;
273
273
}
274
274
@@ -330,16 +330,18 @@ export class Content extends Ion implements OnDestroy, OnInit {
330
330
const children = this . _elementRef . nativeElement . children ;
331
331
assert ( children && children . length >= 2 , 'content needs at least two children' ) ;
332
332
333
- this . _fixedEle = children [ 0 ] ;
334
- this . _scrollEle = children [ 1 ] ;
333
+ const scroll = this . _scroll ;
334
+
335
+ scroll . ev . fixedElement = this . _fixedEle = children [ 0 ] ;
336
+ scroll . ev . scrollElement = this . _scrollEle = children [ 1 ] ;
335
337
336
338
// subscribe to the scroll start
337
- this . _scroll . scrollStart . subscribe ( ev => {
339
+ scroll . scrollStart . subscribe ( ev => {
338
340
this . ionScrollStart . emit ( ev ) ;
339
341
} ) ;
340
342
341
343
// subscribe to every scroll move
342
- this . _scroll . scroll . subscribe ( ev => {
344
+ scroll . scroll . subscribe ( ev => {
343
345
// remind the app that it's currently scrolling
344
346
this . _app . setScrolling ( ) ;
345
347
@@ -350,7 +352,7 @@ export class Content extends Ion implements OnDestroy, OnInit {
350
352
} ) ;
351
353
352
354
// subscribe to the scroll end
353
- this . _scroll . scrollEnd . subscribe ( ev => {
355
+ scroll . scrollEnd . subscribe ( ev => {
354
356
this . ionScrollEnd . emit ( ev ) ;
355
357
356
358
this . imgsUpdate ( ) ;
@@ -576,6 +578,8 @@ export class Content extends Ion implements OnDestroy, OnInit {
576
578
this . _fTop = 0 ;
577
579
this . _fBottom = 0 ;
578
580
581
+ const scrollEvent = this . _scroll . ev ;
582
+
579
583
let ele : HTMLElement = this . _elementRef . nativeElement ;
580
584
if ( ! ele ) {
581
585
assert ( false , 'ele should be valid' ) ;
@@ -590,6 +594,8 @@ export class Content extends Ion implements OnDestroy, OnInit {
590
594
ele = < HTMLElement > children [ i ] ;
591
595
tagName = ele . tagName ;
592
596
if ( tagName === 'ION-CONTENT' ) {
597
+ scrollEvent . contentElement = ele ;
598
+
593
599
// ******** DOM READ ****************
594
600
this . scrollWidth = ele . scrollWidth ;
595
601
// ******** DOM READ ****************
@@ -605,10 +611,14 @@ export class Content extends Ion implements OnDestroy, OnInit {
605
611
}
606
612
607
613
} else if ( tagName === 'ION-HEADER' ) {
614
+ scrollEvent . headerElement = ele ;
615
+
608
616
// ******** DOM READ ****************
609
617
this . _hdrHeight = ele . clientHeight ;
610
618
611
619
} else if ( tagName === 'ION-FOOTER' ) {
620
+ scrollEvent . footerElement = ele ;
621
+
612
622
// ******** DOM READ ****************
613
623
this . _ftrHeight = ele . clientHeight ;
614
624
this . _footerEle = ele ;
@@ -793,7 +803,7 @@ export class Content extends Ion implements OnDestroy, OnInit {
793
803
794
804
}
795
805
796
- export function updateImgs ( imgs : Img [ ] , scrollTop : number , scrollHeight : number , scrollDirectionY : ScrollDirection , requestableBuffer : number , renderableBuffer : number ) {
806
+ export function updateImgs ( imgs : Img [ ] , scrollTop : number , scrollHeight : number , scrollDirectionY : string , requestableBuffer : number , renderableBuffer : number ) {
797
807
// ok, so it's time to see which images, if any, should be requested and rendered
798
808
// ultimately, if we're scrolling fast then don't bother requesting or rendering
799
809
// when scrolling is done, then it needs to do a check to see which images are
@@ -809,7 +819,7 @@ export function updateImgs(imgs: Img[], scrollTop: number, scrollHeight: number,
809
819
for ( var i = 0 , ilen = imgs . length ; i < ilen ; i ++ ) {
810
820
img = imgs [ i ] ;
811
821
812
- if ( scrollDirectionY === ScrollDirection . Up ) {
822
+ if ( scrollDirectionY === 'up' ) {
813
823
// scrolling up
814
824
if ( img . top < scrollBottom && img . bottom > scrollTop - renderableBuffer ) {
815
825
// scrolling up, img is within viewable area
@@ -870,7 +880,7 @@ export function updateImgs(imgs: Img[], scrollTop: number, scrollHeight: number,
870
880
// update all imgs which are viewable
871
881
priority1 . sort ( sortTopToBottom ) . forEach ( i => i . update ( ) ) ;
872
882
873
- if ( scrollDirectionY === ScrollDirection . Up ) {
883
+ if ( scrollDirectionY === 'up' ) {
874
884
// scrolling up
875
885
priority2 . sort ( sortTopToBottom ) . reverse ( ) . forEach ( i => i . update ( ) ) ;
876
886
0 commit comments