
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@beta-lib/energy-progress
Advanced tools
一个基于 TypeScript 开发的能量进度条库,用于可视化时间线数据和历史观看记录。它通过 SVG 技术实现了一个具有贝塞尔曲线效果的进度条,支持交互和动画效果。
一个基于 TypeScript 开发的能量进度条库,用于可视化时间线数据和历史观看记录。它通过 SVG 技术实现了一个具有贝塞尔曲线效果的进度条,支持交互和动画效果。
npm install @beta-lib/energy-progress
yarn add @beta-lib/energy-progress
pnpm add @beta-lib/energy-progress
import EnergyPro from '@beta-lib/energy-progress';
// 创建进度条实例
const progress = new EnergyPro({
timeLine: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
endTime: 100,
activeColor: '#00a1d6',
normalCorlor: 'white',
opacity: 0.2,
segCount: 20,
canClickJump: true,
onClickCall: (percent) => {
console.log('Jump to:', percent);
},
onFinish: (history) => {
console.log('Completed! History:', history);
}
});
// 挂载到 DOM 元素
progress.mount('#progress-container');
// 控制进度
progress.timeRun(50); // 运行到 50%
progress.timeJump(80); // 跳转到 80%
new EnergyPro(options: ProgressOptionsParams, segment?: Array<number> | null)
options:配置选项,包含以下属性:
activeColor:已激活部分(历史观看段落)的颜色,默认值为 '#00a1d6'normalCorlor:未激活部分的颜色,默认值为 'white'opacity:整个进度条的透明度,默认值为 0.2scaleFactor:缩放因子,值越大高低差越不明显,默认值为 1timeLine:时间线数据,用于记录时间轴中数据分布密集度,可以是数字数组或对象数组timeKey:时间轴数组中对象的时间关键字,若 timeLine 为对象数组时必传segCount:需要平均分割成几段,默认值为 20endTime:结束时间,用于计算时间分片startPoint:开始点位,用于设置初始时间线,默认值为 0useDefaultSize:是否启用默认边界值,用于限制当数量过少或过多时时间片绘制的范围,默认值为 falsedefaultMaxHeight:最大高度,用于设置最大值的高度,默认值为 200defaultMinHeight:最小高度,用于设置最小值的高度,默认值为 10history:历史观看段落,默认值为 []canClickJump:是否可以点击跳转,默认值为 trueonClickCall:点击跳转后的回调函数,默认值为 () => {}onFinish:到达结束点的回调函数,默认值为 () => {}segment:分段信息,点位数等于分段数+1,默认值为 null
挂载进度条到指定元素。
重新加载进度条配置。
设置进度线位置,用于点击跳转。
设置进度线行进,用于播放时的自动推进,并记录历史段落信息。
返回当前历史段落,已合并重叠范围。
s(开始位置)和 e(结束位置)属性坐标点接口。
interface Point {
x: number; // 坐标x
y: number; // 坐标y
}
时间数据项接口。
interface TimeDataItem {
[key: string]: number;
}
历史观看段落接口。
interface HistoryObj {
s: number; // 开始位置
e: number; // 结束位置
}
进度条配置选项接口。
interface ProgressOptions {
activeColor: string; // 已激活,历史观看段落的颜色
normalCorlor: string; // 未观看颜色
opacity: number; // 整个进度条透明度
scaleFactor: number; // 缩放因子,这个值越大高低差越不明显,为1时高低差最明显
timeLine: Array<TimeDataItem> | Array<number>; // 时间线,用于记录时间轴中数据分步密集度
timeKey: string; // 时间轴数组中对象的时间关键字,若Array<T> T为对象时,必传
segCount: number; // 需要平均分割成几段
endTime: number; // 结束时间
startPoint: number; // 开始点位
history: Array<HistoryObj>; // 历史观看段落
canClickJump: boolean; // 是否可以点击跳转
onClickCall: (p: number) => void; // 点击svg后的触发函数
onFinish: (arr: Array<HistoryObj>) => void; // 到达结束点的触发函数
}
进度条配置选项参数接口(所有属性可选)。
interface ProgressOptionsParams {
activeColor?: string; // 已激活,历史观看段落的颜色
normalCorlor?: string; // 未观看颜色
opacity?: number; // 整个进度条透明度
scaleFactor?: number; // 缩放因子,这个值越大高低差越不明显,为1时高低差最明显
timeLine: Array<TimeDataItem> | Array<number>; // 时间线,用于记录时间轴中数据分步密集度
timeKey?: string; // 时间轴数组中对象的时间关键字,若Array<T> T为对象时,必传
segCount?: number; // 需要平均分割成几段
endTime: number; // 结束时间
startPoint?: number; // 开始点位
history?: Array<HistoryObj>; // 历史观看段落
canClickJump?: boolean; // 是否可以点击跳转
onClickCall?: (p: number) => void; // 点击svg后的触发函数
onFinish?: (arr: Array<HistoryObj>) => void; // 到达结束点的触发函数
}
import EnergyPro from '@beta-lib/energy-progress';
// 创建进度条实例
const progress = new EnergyPro({
timeLine: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
endTime: 100
});
// 挂载到 DOM 元素
progress.mount('#progress-container');
import EnergyPro from '@beta-lib/energy-progress';
// 创建进度条实例
const progress = new EnergyPro({
timeLine: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
endTime: 100,
history: [
{ s: 0, e: 25 },
{ s: 50, e: 75 }
]
});
// 挂载到 DOM 元素
progress.mount('#progress-container');
// 模拟播放
let currentProgress = 0;
const interval = setInterval(() => {
currentProgress += 1;
progress.timeRun(currentProgress);
if (currentProgress >= 100) {
clearInterval(interval);
}
}, 100);
import EnergyPro from '@beta-lib/energy-progress';
// 创建进度条实例
const progress = new EnergyPro({
timeLine: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
endTime: 100,
canClickJump: true,
onClickCall: (percent) => {
console.log('User clicked at:', percent, '%');
// 可以在这里添加跳转逻辑
}
});
// 挂载到 DOM 元素
progress.mount('#progress-container');
const ep = new EnergyPro({
segCount: 10, // 需要平均分割成几段
useDefaultSize: true, // 是否启用默认极限值
defaultMaxHeight: 200, // 最大高度,用于设置最大值的高度(数量)
defaultMinHeight: 10, // 最小高度,用于设置最小值的高度(数量)
}, [55, 54, 50, 58, 46, 10, 44, 50, 52, 45, 6]);
// 挂载到 DOM 元素
progress.mount('#progress-container');
FAQs
一个基于 TypeScript 开发的能量进度条库,用于可视化时间线数据和历史观看记录。它通过 SVG 技术实现了一个具有贝塞尔曲线效果的进度条,支持交互和动画效果。
The npm package @beta-lib/energy-progress receives a total of 7 weekly downloads. As such, @beta-lib/energy-progress popularity was classified as not popular.
We found that @beta-lib/energy-progress demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.