mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-02-04 05:07:59 +08:00
content docs wip
This commit is contained in:
@@ -6,7 +6,9 @@ import {IonicComponent} from '../../config/annotations';
|
||||
import {ScrollTo} from '../../animations/scroll-to';
|
||||
import {hasFocusedTextInput} from '../../util/dom';
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ion-content',
|
||||
properties: [
|
||||
@@ -17,15 +19,28 @@ import {hasFocusedTextInput} from '../../util/dom';
|
||||
template: '<scroll-content><ng-content></ng-content></scroll-content>'
|
||||
})
|
||||
export class Content extends Ion {
|
||||
/**
|
||||
* TODO
|
||||
* @param {ElementRef} elementRef TODO
|
||||
* @param {IonicConfig} config TODO
|
||||
*/
|
||||
constructor(elementRef: ElementRef, config: IonicConfig) {
|
||||
super(elementRef, config);
|
||||
this.scrollPadding = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
onIonInit() {
|
||||
this.scrollElement = this.getNativeElement().children[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified scroll handler to the content' scroll element.
|
||||
* @param {Function} handler The scroll event handler.
|
||||
* @returns {Function} A function that removes the scroll handler.
|
||||
*/
|
||||
addScrollEventListener(handler) {
|
||||
if(!this.scrollElement) { return; }
|
||||
|
||||
@@ -39,6 +54,11 @@ export class Content extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified touchmove handler to the content's scroll element.
|
||||
* @param {Function} handler The touchmove handler.
|
||||
* @returns {Function} A function that removes the touchmove handler.
|
||||
*/
|
||||
addTouchMoveListener(handler) {
|
||||
if(!this.scrollElement) { return; }
|
||||
|
||||
@@ -52,6 +72,14 @@ export class Content extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll to the specified position.
|
||||
* @param {TODO} x TODO
|
||||
* @param {TODO} y TODO
|
||||
* @param {Number} duration Duration of the scroll animation.
|
||||
* @param {TODO} tolerance TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
scrollTo(x, y, duration, tolerance) {
|
||||
if (this._scrollTo) {
|
||||
this._scrollTo.dispose();
|
||||
@@ -62,6 +90,22 @@ export class Content extends Ion {
|
||||
return this._scrollTo.start(x, y, duration, tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content and scroll elements' dimensions.
|
||||
* @returns {Object} dimensions The content and scroll elements' dimensions
|
||||
* @returns {Number} dimensions.contentHeight content offsetHeight
|
||||
* @returns {Number} dimensions.contentTop content offsetTop
|
||||
* @returns {Number} dimensions.contentBottom content offsetTop+offsetHeight
|
||||
* @returns {Number} dimensions.contentWidth content offsetWidth
|
||||
* @returns {Number} dimensions.contentLeft content offsetLeft
|
||||
* @returns {Number} dimensions.contentRight content offsetLeft + offsetWidth
|
||||
* @returns {Number} dimensions.scrollHeight scroll scrollHeight
|
||||
* @returns {Number} dimensions.scrollTop scroll scrollTop
|
||||
* @returns {Number} dimensions.scrollBottom scroll scrollTop + scrollHeight
|
||||
* @returns {Number} dimensions.scrollWidth scroll scrollWidth
|
||||
* @returns {Number} dimensions.scrollLeft scroll scrollLeft
|
||||
* @returns {Number} dimensions.scrollRight scroll scrollLeft + scrollWidth
|
||||
*/
|
||||
getDimensions() {
|
||||
let scrollElement = this.scrollElement;
|
||||
let parentElement = scrollElement.parentElement;
|
||||
@@ -85,6 +129,11 @@ export class Content extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Adds padding to the bottom of the scroll element when the keyboard is open
|
||||
* so content below the keyboard can be scrolled into view.
|
||||
*/
|
||||
addKeyboardPadding(addPadding) {
|
||||
if (addPadding > this.scrollPadding) {
|
||||
this.scrollPadding = addPadding;
|
||||
@@ -92,6 +141,9 @@ export class Content extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
pollFocus() {
|
||||
if (hasFocusedTextInput()) {
|
||||
this.isPollingFocus = true;
|
||||
|
||||
Reference in New Issue
Block a user