Coder Social home page Coder Social logo

dinert-time-player's Introduction

自适应时间轴播放器

前言

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

效果

image

预览地址

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

技术栈

vue vue

如何安装

  • 如果你使用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 当前时间 Date new Date()
stopTime 时间轴停止的时间 Date new Date()
formatFooter 底部时间格式化 String YYYY年MM月DD日
formatTooltip tooltip时间格式化 String YYYY年MM月DD日 HH时
interval 24小时时间的间隔 Number 3
delay 播放时间的间隔 Number 2000

方法

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

事件

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

参数名称

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

dinert-time-player's People

Contributors

dinert avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.