mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
34 lines
982 B
JavaScript
34 lines
982 B
JavaScript
import {ElementRef} from 'angular2/angular2'
|
|
import {Component} from 'angular2/src/core/annotations_impl/annotations';
|
|
import {View} from 'angular2/src/core/annotations_impl/view';
|
|
|
|
|
|
@Component({
|
|
selector: 'ion-content'
|
|
})
|
|
@View({
|
|
template: `<div class="scroll-content"><content></content></div>`
|
|
})
|
|
export class Content {
|
|
constructor(elementRef: ElementRef) {
|
|
// TODO(maxlynch): we need this nativeElement for things like aside, etc.
|
|
// but we should be able to stamp out this behavior with a base IonicComponent
|
|
// or something, so all elements have a nativeElement reference or a getElement() method
|
|
this.ele = elementRef.nativeElement;
|
|
|
|
setTimeout(() => {
|
|
this.scrollElement = this.ele.children[0];
|
|
});
|
|
}
|
|
|
|
addScrollEventListener(handler) {
|
|
if(!this.scrollElement) { return; }
|
|
|
|
this.scrollElement.addEventListener('scroll', handler);
|
|
|
|
return () => {
|
|
this.scrollElement.removeEventListener('scroll', handler);
|
|
}
|
|
}
|
|
}
|