Files
2015-07-30 22:38:45 -05:00

44 lines
1021 B
TypeScript

import {View, ElementRef} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {IonicComponent} from '../../config/annotations';
/**
* ion-scroll is a non-flexboxed scroll area that can
* scroll horizontally or vertically.
*/
@IonicComponent({
selector: 'ion-scroll',
properties: [
'scrollX', 'scrollY'
],
host: {
'[class.scroll-x]': 'scrollX',
'[class.scroll-y]': 'scrollY'
}
})
@View({
template: '<div class="scroll-content"><ng-content></ng-content></div>'
})
export class Scroll extends Ion {
constructor(elementRef: ElementRef, ionicConfig: IonicConfig) {
super(elementRef, ionicConfig);
setTimeout(() => {
this.scrollElement = this.getNativeElement().children[0];
});
}
addScrollEventListener(handler) {
if(!this.scrollElement) { return; }
this.scrollElement.addEventListener('scroll', handler);
return () => {
this.scrollElement.removeEventListener('scroll', handler);
}
}
}