【问题标题】:How to add class on scroll in ionic2如何在ionic2中的滚动上添加类
【发布时间】:2017-04-17 16:02:49
【问题描述】:

我想在我的 Ionic2 应用程序中添加滚动动画,但我无法在滚动中添加类,因此动画不会在滚动时发生,所有动画都会同时触发。 请帮我解决这个问题。

【问题讨论】:

    标签: typescript ionic2


    【解决方案1】:

    基本上ion-content 上提供了一个ionScroll 事件发射器,因此您可以订阅它并做任何您需要的事情。您可以在docs 中找到更多信息。

    这是一个例子:

    模板.html

    <ion-content #content></ion-content>
    

    component.js

    import { Component, ViewChild } from '@angular/core'
    
    @Component({...})
    export class Component {
      @ViewChild('content') content = null
    
      ngAfterViewInit() {
        this.content.ionScroll.subscribe(event => {
          // do what you need here
          console.log(event)
        })
      }
    }
    

    【讨论】:

    • 先生,谢谢您的回复,但我希望每个部分都像 link 这样的动画。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-21
    • 2018-11-09
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多