2016-12-24 1 views

답변

4

당신은 Content에 대한 참조를 사용할 수 있습니다

import { Component, ViewChild } from '@angular/core'; 
import { Content } from 'ionic-angular'; 

@Component({...}) 
export class MyPage{ 
    @ViewChild(Content) content: Content; 

    scrollToTop() { 
    this.content.scrollToTop(); 
    } 

    scrollTo(elementId:string) { 
    let yOffset = document.getElementById(elementId).offsetTop; 
    this.content.scrollTo(0, yOffset, 4000) 
    } 
} 

사용할 수있는 특성이 많이있다; 가장 큰 수입품 중 하나는 ...

getContentDimensions() : 요소 및 치수를 반환합니다.

Property     Type Details 
dimensions.contentHeight number content offsetHeight 
dimensions.contentTop  number content offsetTop 
dimensions.contentBottom number content offsetTop+offsetHeight 
dimensions.contentWidth  number content offsetWidth 
dimensions.contentLeft  number content offsetLeft 
dimensions.contentRight  number content offsetLeft + offsetWidth 
dimensions.scrollHeight  number scroll scrollHeight 
dimensions.scrollTop  number scroll scrollTop 
dimensions.scrollBottom  number scroll scrollTop + scrollHeight 
dimensions.scrollWidth  number scroll scrollWidth 
dimensions.scrollLeft  number scroll scrollLeft 
dimensions.scrollRight  number scroll scrollLeft + scrollWidth