Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@losting/timeline

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@losting/timeline

canvas timeline

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
decreased by-43.24%
Maintainers
1
Weekly downloads
 
Created
Source

timeline

canvas 时间轴,支持缩放、拖拽、无限滚动 preview

使用

npm install @losting/timeline
<div id="root" style="width: 100%;height: 70px;">
  <canvas id="timeline"></canvas>
</div>
import Timeline from '@losting/timeline';

// new Timeline(canvasId, options)
const timeline = new Timeline('timeline', {
  fill: true,
});

timeline.draw({
  currentTime: 1651829532,
  areas: [{
    startTime: 1651827433,
    endTime: 1651829413,
    // bgColor: '#00AEEC55'
  },{
    startTime: 1651829533,
    endTime: 1651832533,
    // bgColor: '#00AEEC55'
  }],
});

timeline.on('timeUpdate', (time) => {
  console.log('selected time:', time);
})

TimeLine options

属性类型默认值说明
widthnumbercanvas宽度
heightnumbercanvas高度
fillbooleanfalse是否适应父容器宽高,若为false则需要手动设定canvas宽高
bgColorstringrgba(0,0,0,0.5)canvas背景色
textColorstring#ffffff文字颜色
scaleColorstring#ffffff刻度颜色
scaleSpacingnumber7刻度间距
areaBgColorstring#ffffff55阴影区域背景颜色
pointColorstring#00aeec当前时间指针颜色
pointWidthnumber3当前时间指针宽度
fpsnumber60绘制帧率。数字越大越流畅
zoomnumber2缩放比,1~9之间的正整数
maxZoomnumber9最大缩放限制,1~9之间的正整数
minZoomnumber1最小缩放限制,1~9之间的正整数

事件

方法名说明
draw生成时间轴,参数:object,返回值:无
on事件监听。参数:timeUpdate, 返回值:当前指向时间
draw方法
参数类型是否必填说明
currentTimenumber当前所在时间,默认为当前时间
areasarray阴影区域
areas
参数类型是否必填说明
startTimenumber阴影区域开始时间
endTimenumber阴影区域结束时间点
bgColorstring背景颜色, 默认值:#ffffff55

Keywords

FAQs

Package last updated on 18 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc