docs(content): add note about scroll events and zone

Closes #11633
This commit is contained in:
mhartington
2017-06-07 14:01:55 -04:00
parent 5d2974f2d2
commit fe751f7ac3

View File

@ -63,7 +63,44 @@ export class EventEmitterProxy<T> extends EventEmitter<T> {
*
* @advanced
*
* Resizing the content. If the height of `ion-header`, `ion-footer` or `ion-tabbar`
* ### Sroll Events
*
* Scroll events happen outside of Angular's Zones. This is for performance reasons. So
* if you're trying to bind a value to any scroll event, it will need to be wrapped in
* a `zone.run()`
*
* ```ts
* import { Component, NgZone } from '@angular/core';
* @Component({
* template: `
* <ion-header>
* <ion-navbar>
* <ion-title>{{scrollAmount}}</ion-title>
* </ion-navbar>
* </ion-header>
* <ion-content (ionScroll)="scrollHandler($event)">
* <p> Some realllllllly long content </p>
* </ion-content>
* `})
* class E2EPage {
* public scrollAmount = 0;
* constructor( public zone: NgZone){}
* scrollHandler(event) {
* console.log(`ScrollEvent: ${event}`)
* this.zone.run(()=>{
* // since scrollAmount is data-binded,
* // the update needs to happen in zone
* this.scrollAmount++
* })
* }
* }
* ```
*
* This goes for any scroll event, not just `ionScroll`.
*
* ### Resizing the content
*
* If the height of `ion-header`, `ion-footer` or `ion-tabbar`
* changes dynamically, `content.resize()` has to be called in order to update the
* layout of `Content`.
*