transition-group无缝滚动组件

在这里插入图片描述

1<template>
  <div style="padding: 40px 0 0 40px;"
       >
    <transition-group
      :appear="true"
      name="flip-list"
      tag="ul"
      :css="false"
      class="flip-list"
      @mouseenter.native="mouseEnter"
      @mouseleave.native="bannerText"
    >
      <li
        v-for="(item, index) in listData"
        :key="item.id"
        :class="{active: index === 1}">
        <span>{{item.title }}{{ item.date}}</span>
      </li>
    </transition-group>
  </div>
</template>

<script>
export default {
  name: 'textBanner',
  data () {
    return {
      listData: [{
        title: '无缝滚动第一行',
        date: '2017-12-16',
        id: '001'
      }, {
        title: '无缝滚动第二行 ',
        date: '2017-12-16',
        id: '002'
      }, {
        title: '无缝滚动第三行 ',
        date: '2017-12-16',
        id: '003'
      }, {
        title: '无缝滚动第四行 ',
        date: '2017-12-16',
        id: '004'
      }, {
        title: '无缝滚动第五行 ',
        date: '2017-12-16',
        id: '005'
      }, {
        title: '无缝滚动第六行 ',
        date: '2017-12-16',
        id: '006'
      }, {
        title: '无缝滚动第七行 ',
        date: '2017-12-16',
        id: '007'
      }, {
        title: '无缝滚动第八行 ',
        date: '2017-12-16',
        id: '008'
      }, {
        title: '无缝滚动第九行 ',
        date: '2017-12-16',
        id: '009'
      }],
      timer: null
    };
  },
  computed: {
  },
  methods: {
    toggleList () {
      const lastItem = this.listData.splice(0, 1);
      this.$nextTick(() => {
        this.listData.push(...lastItem);
      });
    },
    mouseEnter () {
      if (this.timer) {
        clearInterval(this.timer);
      }
    },
    bannerText () {
      if (this.timer) {
        clearInterval(this.timer);
      }
      this.timer = setInterval(() => {
        this.toggleList();
      }, 3000);
    }
  },
  mounted () {
    this.bannerText();
  },
  beforeDestroy () {
  },
  watch: {
    // handler immediate deep
  },
  components: {
  }
}
</script>

<style scoped lang="less">
  .seamless-warp {
    height: 89px;
    width: 300px;
    overflow: hidden;
  }
  .item {
    li {
      height: 30px;
      line-height: 30px;
      border-bottom: 1px solid #ddd;
      text-align: center;
      font-size: 12px;
      color: #999;
    }
    li.curr {
      font-size: 16px;
      color: #000;
    }
  }
  .flip-list {
    list-style: none;
    height: 89px;
    width: 300px;
    overflow: hidden;
    li {
      height: 30px;
      line-height: 30px;
      border-bottom: 1px solid #ddd;
      text-align: center;
      cursor: pointer;
      span {
        font-size: 12px;
        color: #999;
        transition: all 500ms;
      }
    }
    li.active {
      span {
        font-size: 16px;
        color: #f8ae00;
      }
    }
  }
  .flip-list-move {
    transition: transform 500ms;
  }

</style>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值