1.0.47 • Published 2 years ago

@dinert/time-player v1.0.47

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

自适应时间轴播放器

前言

  • 这是一个从0到1实现的时间轴播放器,除了时间格式化用了第三库
  • 支持TypeScript
  • 有两种主题,默认是dark。class设置为light为白色风格

效果

image

预览地址

https://dinert.github.io/dinert-time-player/

技术栈

如何安装

  • 如果你使用npm
npm i @dienrt/time-player dayjs --save
  • 或者使用yarn
yarn add @dinert/time-player dayjs

全局引入

import Vue from 'vue'
import App from './App.vue'
import DinerTimePlayer from '@dinert/time-player'
import '@dinert/time-player/style'
Vue.use(DinerTimePlayer)

new Vue({
    render: h => h(App)
}).$mount('#app')

按需导入

  import {DinertTimePlayer} from '@dinert/time-player'
  import '@dinert/time-player/style'
  export default {
    components: {
      DinertTimePlayer
    }
  }

使用

<template>
    <div class="app">
        <dinert-time-player ref="timePlayerRef" :current-time="currentTime"
            @animate-before="animateBefore"
            @animate-after="animateAfter"
        />
        <div class="button">
            <button type="button" @click="$refs.timePlayerRef.startPlay()">开始播放</button>
            <button type="button" @click="$refs.timePlayerRef.stopPlay()">停止播放</button>
        </div>
    </div>
</template>

<script>
  import {DinertTimePlayer} from '@dinert/time-player'
import '@dinert/time-player/style'
export default {
    name: 'Home',
    components: {
        DinertTimePlayer
    },
    data() {
        return {
            currentTime: new Date(),
        }
    },
    methods: {
        animateBefore(config) {
            console.log(config, 'animateBefore')
        },
        animateAfter(config) {
            console.log(config, 'animateAfter')
        }
    }
}
</script>

<style lang="scss" scoped>

.app {
    margin-top: 80px;
}

.button {
    margin: 20px auto;
    text-align: center;

    button {
        margin-left: 20px;
    }
}
</style>

属性

参数说明类型可选值默认值
startTime开始时间Date当前时间的前两天
endTime结束时间Date当前时间的后两天
currentTime当前时间Datenew Date()
stopTime时间轴停止的时间Datenew Date()
formatFooter底部时间格式化StringYYYY年MM月DD日
formatTooltiptooltip时间格式化StringYYYY年MM月DD日 HH时
interval24小时时间的间隔Number3
delay播放时间的间隔Number2000

方法

参数说明类型
startPlay开始播放,请求数据完成,开始播放Function
stopPlay停止播放,后台请求数据的时间就可以停止播放Function

事件

参数说明参数类型
animate-before当点击时间轴触发看下表Function
animate-after当点击时间轴动画完成后触发看下表Function

参数名称

名称说明类型
time当前时间String
width宽度number
percent当前时间所占整体时间条的百分比number
timestamp当前时间的时间戳number
1.0.1

2 years ago

0.0.0

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.0

3 years ago