用角度动画为轮播文本设置动画

时间:2018-11-18 21:01:08

标签: angular animation angular6

轮播字幕出现时,我想制作动画。我已经能够写一个简短的动画。动画仅在刷新时才第一次出现,但在单击指示器时会四舍五入。它不再动画了。

我需要动画始终在任何图像滑入时触发

“ home.component.html”

<div class="row">
<div class="col-12 theSlide">
    <div id="demo" class="carousel slide" data-ride="carousel">
      <ul class="carousel-indicators">
        <li data-target="#demo" data-slide-to="0" class="active"></li>
        <li data-target="#demo" data-slide-to="1"></li>
        <li data-target="#demo" data-slide-to="2"></li>
      </ul>
      <div class="carousel-inner">
        <div class="carousel-item active">
          <img src="/assets/images/slide1.jpg" alt="slide1">
          <div class="carousel-caption slide1" @slideone>
            <h1>STROBOUCH</h1>
            <h4>We're the best in the field</h4>
            <h6> We Know what it takes to be the best, so we work hard to earn our keep </h6>
          </div>   
        </div>
        <div class="carousel-item">
          <img src="/assets/images/slide2.jpg" alt="slide2">
          <div class="carousel-caption">
            <h1>Chicago</h1>
            <h4>Thank you, Chicago!</h4>
          </div>   
        </div>
        <div class="carousel-item">
          <img src="/assets/images/slide3.jpg" alt="slide3">
          <div class="carousel-caption">
            <h1>New York</h1>
            <h4>We love the Big Apple!</h4>
          </div>   
        </div>
      </div>
      <a class="carousel-control-prev" href="#demo" data-slide="prev">
        <span class="carousel-control-prev-icon"></span>
      </a>
      <a class="carousel-control-next" href="#demo" data-slide="next">
        <span class="carousel-control-next-icon"></span>
      </a>
    </div>
</div>

“ home.component.ts”

import { Component, OnInit } from '@angular/core';
import { trigger, animate, state, style, transition, group, query } from '@angular/animations';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css'],
  animations: [
  trigger('slideone', [
    transition("void => *", [
      style({ 
        opacity: 0
      }),
      animate(500)
     ])
  ])
]
})
export class HomeComponent implements OnInit {



  constructor() { }

  ngOnInit() {
  }

}

0 个答案:

没有答案