参考网址:https://www.jianshu.com/p/b6813193ca0d

<template>
<div class="wrap" :style="{height:height + 'px'}">
<div
class="box"
:style="{top: '-' + height + 'px', height: (height * actualMap.length) + 'px'}"
>
<div
class="item"
v-for="(item,index) in actualMap"
:key="index"
@click="showPreview(item)"
:style="{'height':height + 'px','line-height':height + 'px'}"
>
<div
class="inner_content"
:style="{'line-height':height/2 + 'px'}"
>{{item.rollTitle == "" ? item.title : item.rollTitle}}</div>
<div
class="amount_title"
:style="{'line-height':height/2 + 'px'}"
>{{item.pubTm|formatDate2}} · 浏览次数 {{item.viewCount}}</div>
</div>
</div>
</div>
</template> <script>
export default {
name: "selfCarousel", // 自定义标题栏走马灯
props: {
height: {
default: 40,
type: Number
},
contentArr: {
default: [],
type: Array
}
},
data() {
return {
box: null,
timer: undefined,
moveTimer: undefined,
index: 1
};
},
computed: {
actualMap: function() {
let Tmp = this.contentArr
? JSON.parse(JSON.stringify(this.contentArr))
: [];
if (this.contentArr.length > 0) {
Tmp.unshift(this.contentArr[this.contentArr.length - 1]);
Tmp.push(this.contentArr[0]);
}
return Tmp;
}
},
mounted() {
this.box = document.getElementsByClassName("box")[0];
this.inintTimer();
let _this = this;
$(".wrap").hover(
function(e) {
clearInterval(_this.timer);
_this.timer = undefined;
},
function() {
_this.inintTimer();
}
);
},
methods: {
showPreview(row) {
this.$emit("showPreview", row);
},
moveWidthIndex() {
var l = this.index * -this.height - this.box.offsetTop;
var count = 0;
clearInterval(this.moveTimer);
let self = this;
this.moveTimer = setInterval(function() {
count++;
self.box.style.top =
self.box.offsetTop + l / (self.contentArr.length * 2) + "px";
if (count >= self.contentArr.length * 2) {
clearInterval(self.moveTimer);
self.box.style.top = self.index * - self.height + "px";
}
}, 20);
},
nextStep() {
this.index++;
if (this.index == this.actualMap.length) {
this.index = 2;
this.box.style.top = "-" + this.height + "px";
}
this.moveWidthIndex();
},
inintTimer() {
let self = this;
this.timer = setInterval(function() {
self.nextStep();
}, 2000);
}
}
};
</script> <style lang="less" scoped>
.wrap {
width: 100%;
position: relative;
overflow: hidden;
}
.box {
width: 100%;
position: absolute;
}
.item {
width: 100%;
}
.inner_content {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 16px;
color: #333333;
}
.amount_title {
font-size: 14px;
color: #999999;
}
</style>

vue 标题上下滚屏 无缝轮播的更多相关文章

  1. 原生js写一个无缝轮播图插件(支持vue)

    轮播图插件(Broadcast.js) 前言:写这个插件的原因 前段时间准备用vue加上网易云的nodejs接口,模拟网易云音乐移动端.因为想自己写一遍所有的代码以及加固自己的flex布局,所以没有使 ...

  2. JQ无缝轮播图-插件封装

    类似京东的这种无缝轮播效果: 实例代码下载 HTML代码: <body> <!-- /*觅me 探索生活*/ --> <div class="test" ...

  3. 网站banner无缝轮播

    网站banner无缝轮播 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  4. bootstrapcss3触屏滑块轮播图

    插件描述:bootslider响应bootstrapcss3触屏滑块轮播图 小海已经好久没分享技术性文章了,这个基于bootstrap的触屏版轮播图绝对满足大家的胃口,并且支持移动端触摸滑动.功能上, ...

  5. js动画 无缝轮播 进度条 文字页面展示 div弹窗遮罩效果

    1.无缝轮播 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.a ...

  6. jQuery插件slides实现无缝轮播图特效

    初始化插件: slides是一款基于jQuery无缝轮播图插件,支持图内元素动画,可以自定义动画类型 1 2 3 4 5 6 7 8 9 10 $(".slideInner").s ...

  7. 分别用css3、JS实现图片简单的无缝轮播功效

    本文主要介绍分别使用CSS3.JS实现图片简单无缝轮播功效: 一.使用CSS3实现:利用animation属性 (实现一张一张的轮播,肉眼只看见一张图片) HTML部分比较简单,两个div下包着几个i ...

  8. JQuery制作基础的无缝轮播与左右点击效果

    在网页中我们想要的无缝轮播左右循环有好多好多中,这是我第一个轮播效果,也是最基础的,和大家分享一下,对于初学者希望你们能有所借鉴,对于大神我想让你们尽情的虐我给我宝贵的意见. 这个是我要的效果 进入正 ...

  9. jQuery图片无缝轮播

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

随机推荐

  1. Redis 常用命令学习二:字符串类型命令

    1.赋值与取值命令 127.0.0.1:6379> set foo helloredis OK 127.0.0.1:6379> get foo "helloredis" ...

  2. mysql中information_schema.tables字段说明

      1. 获取所有表结构(TABLES) SELECT  *  FROM information_schema.TABLES WHERE  TABLE_SCHEMA='数据库名';  TABLES表: ...

  3. protobuf 序列化 使用

    protocol buff是一种协议,是谷歌推出的一种序列化协议 .Java序列化协议也是一种协议 两者的目的是,将对象序列化成字节数组,或者说是二进制数据 导包 <dependency> ...

  4. Spring AOP 简介(三)

    Spring AOP 简介 如果说 IoC 是 Spring 的核心,那么面向切面编程就是 Spring 最为重要的功能之一了,在数据库事务中切面编程被广泛使用. AOP 即 Aspect Orien ...

  5. VC++:创建,调用Win32静态链接库

    概述 DLL(Dynamic Linkable Library)动态链接库,Dll可以看作一种仓库,仓库中包含了可以直接使用的变量,函数或类. 仓库的发展史经历了"无库" ---& ...

  6. Linux centos 7下搭建mosquitto

    Centos7安装 1.网卡名改为enth0 A:  vim /etc/sysconfig/grub B:  第三行添加"net.ifnames=0 biosdevname=0" ...

  7. 【Pandas数据分析案例】2018年北京积分入户情况分析

    据说,北京落户的难度比加入美国国籍还高.而北京2018年首次实行积分入户制,让我们来分析一下首批通过积分入户拿到北京户口的数据. 首先从北京积分落户官网下载公示名单: 根据表格中的信息,我们主要从以下 ...

  8. PAT(B) 1010 一元多项式求导(Java)

    题目链接:1010 一元多项式求导 代码 /** * Score 25 * Run Time 94ms * @author wowpH * @version 1.1 */ import java.ut ...

  9. scratch少儿编程第一季——04、想要做到有的放矢,瞄准方向很重要

    各位小伙伴大家好: 上期我们学习了动作模块的前面三个指令,今天我们继续学习下面的5个指令. 首先来看第一个(控制方向): 面向90方向默认就是屏幕的右边. 点击白色文本框上面的▼可以打开下拉菜单. 大 ...

  10. 无法访问VMWARE虚拟机中linux的nginx地址

    取得root权限,然后在centos(6.5)中关闭防火墙: service iptables stop 关闭后在windows 10 中浏览器通过虚拟机的ip地址可以直接访问了. 经过测试,打开ip ...