mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
chore(content): scrollElement private
This commit is contained in:
@ -40,11 +40,7 @@ export class Content extends Ion {
|
|||||||
private _padding: number = 0;
|
private _padding: number = 0;
|
||||||
private _scroll: ScrollView;
|
private _scroll: ScrollView;
|
||||||
private _scLsn: Function;
|
private _scLsn: Function;
|
||||||
|
private _scrollEle: HTMLElement;
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
scrollElement: HTMLElement;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _elementRef: ElementRef,
|
private _elementRef: ElementRef,
|
||||||
@ -66,10 +62,10 @@ export class Content extends Ion {
|
|||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let self = this;
|
let self = this;
|
||||||
self.scrollElement = self._elementRef.nativeElement.children[0];
|
self._scrollEle = self._elementRef.nativeElement.children[0];
|
||||||
|
|
||||||
self._zone.runOutsideAngular(function() {
|
self._zone.runOutsideAngular(function() {
|
||||||
self._scroll = new ScrollView(self.scrollElement);
|
self._scroll = new ScrollView(self._scrollEle);
|
||||||
|
|
||||||
if (self._config.getBoolean('tapPolyfill')) {
|
if (self._config.getBoolean('tapPolyfill')) {
|
||||||
self._scLsn = self.addScrollListener(function() {
|
self._scLsn = self.addScrollListener(function() {
|
||||||
@ -85,7 +81,7 @@ export class Content extends Ion {
|
|||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this._scLsn && this._scLsn();
|
this._scLsn && this._scLsn();
|
||||||
this._scroll && this._scroll.destroy();
|
this._scroll && this._scroll.destroy();
|
||||||
this.scrollElement = this._scLsn = null;
|
this._scrollEle = this._scLsn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,15 +157,16 @@ export class Content extends Ion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _addListener(type: string, handler: any): Function {
|
private _addListener(type: string, handler: any): Function {
|
||||||
if (!this.scrollElement) { return; }
|
if (!this._scrollEle) { return; }
|
||||||
|
|
||||||
// ensure we're not creating duplicates
|
// ensure we're not creating duplicates
|
||||||
this.scrollElement.removeEventListener(type, handler);
|
this._scrollEle.removeEventListener(type, handler);
|
||||||
this.scrollElement.addEventListener(type, handler);
|
this._scrollEle.addEventListener(type, handler);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (!this.scrollElement) { return; }
|
if (this._scrollEle) {
|
||||||
this.scrollElement.removeEventListener(type, handler);
|
this._scrollEle.removeEventListener(type, handler);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +178,7 @@ export class Content extends Ion {
|
|||||||
onScrollEnd(callback: Function) {
|
onScrollEnd(callback: Function) {
|
||||||
let lastScrollTop = null;
|
let lastScrollTop = null;
|
||||||
let framesUnchanged = 0;
|
let framesUnchanged = 0;
|
||||||
let _scrollEle = this.scrollElement;
|
let _scrollEle = this._scrollEle;
|
||||||
|
|
||||||
function next() {
|
function next() {
|
||||||
let currentScrollTop = _scrollEle.scrollTop;
|
let currentScrollTop = _scrollEle.scrollTop;
|
||||||
@ -209,7 +206,7 @@ export class Content extends Ion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onScrollElementTransitionEnd(callback: Function) {
|
onScrollElementTransitionEnd(callback: Function) {
|
||||||
transitionEnd(this.scrollElement, callback);
|
transitionEnd(this._scrollEle, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -312,7 +309,7 @@ export class Content extends Ion {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
setScrollElementStyle(prop: string, val: any) {
|
setScrollElementStyle(prop: string, val: any) {
|
||||||
this.scrollElement.style[prop] = val;
|
this._scrollEle.style[prop] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,7 +329,7 @@ export class Content extends Ion {
|
|||||||
* {number} dimensions.scrollRight scroll scrollLeft + scrollWidth
|
* {number} dimensions.scrollRight scroll scrollLeft + scrollWidth
|
||||||
*/
|
*/
|
||||||
getContentDimensions() {
|
getContentDimensions() {
|
||||||
let _scrollEle = this.scrollElement;
|
let _scrollEle = this._scrollEle;
|
||||||
let parentElement = _scrollEle.parentElement;
|
let parentElement = _scrollEle.parentElement;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -364,7 +361,7 @@ export class Content extends Ion {
|
|||||||
console.debug('content addScrollPadding', newPadding);
|
console.debug('content addScrollPadding', newPadding);
|
||||||
|
|
||||||
this._padding = newPadding;
|
this._padding = newPadding;
|
||||||
this.scrollElement.style.paddingBottom = newPadding + 'px';
|
this._scrollEle.style.paddingBottom = newPadding + 'px';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user