Skip to content

Commit

Permalink
release: v0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
imtaotao committed Oct 26, 2024
1 parent 2054448 commit c9e5dac
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
12 changes: 10 additions & 2 deletions docs/en/reference/manager-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,17 @@ manager.pushFlexibleDanmaku('content', {

## `manager.getTrack()`

**Type: `(i: number) => Track<T>`**
**类型:`(i: number) => Track<T>`**

获取某个具体的轨道,轨道的 API 见 [**`Track API`**](./track-api)
获取某个具体的轨道,下标默认从 0 开始,如果下标为负数,则从后往前取,轨道的 API 见 [**`轨道 API`**](./track-api)

```ts
// 获取第一条轨道
const track = manager.getTrack(0);

// 获取最后一条轨道
const track = manager.getTrack(-1);
```

## `manager.len()`

Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/track-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ manager.pushFlexibleDanmaku(

**类型:`() => void`**

用于锁定当前轨道,当轨道被锁定之后,当前这条弹幕将不会发送新的弹幕
用于锁定当前轨道,当轨道被锁定之后,当前这条轨道将不会发送新的弹幕

## track.unlock()

Expand Down
10 changes: 9 additions & 1 deletion docs/zh/reference/manager-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,15 @@ manager.pushFlexibleDanmaku('弹幕内容', {

**类型:`(i: number) => Track<T>`**

获取某个具体的轨道,轨道的 API 见 [**`轨道 API`**](./track-api)
获取某个具体的轨道,下标默认从 0 开始,如果下标为负数,则从后往前取,轨道的 API 见 [**`轨道 API`**](./track-api)

```ts
// 获取第一条轨道
const track = manager.getTrack(0);

// 获取最后一条轨道
const track = manager.getTrack(-1);
```

## `manager.len()`

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/reference/track-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ manager.pushFlexibleDanmaku(

**类型:`() => void`**

用于锁定当前轨道,当轨道被锁定之后,当前这条弹幕将不会发送新的弹幕
用于锁定当前轨道,当轨道被锁定之后,当前这条轨道将不会发送新的弹幕

## track.unlock()

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "danmu",
"version": "0.13.0",
"version": "0.14.0",
"description": "Flexible, cross-platform, powerful danmu library.",
"main": "./dist/danmu.cjs.js",
"unpkg": "./dist/danmu.umd.js",
Expand Down
8 changes: 4 additions & 4 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export class Engine<T> {
const track = this.tracks[i];
const top = h * i;
const bottom = h * (i + 1) - 1;
const midile = (bottom - top) / 2 + top;
const location = { top, midile, bottom };
const middle = (bottom - top) / 2 + top;
const location = { top, middle, bottom };

if (bottom > this.container.height) {
this.rows--;
Expand All @@ -159,7 +159,7 @@ export class Engine<T> {
} else if (track) {
// If the reused track is larger than the container height,
// the overflow needs to be deleted.
if (track.location.midile > this.container.height) {
if (track.location.middle > this.container.height) {
this.tracks[i].clear();
} else {
track.each((dm) => {
Expand Down Expand Up @@ -348,7 +348,7 @@ export class Engine<T> {
if (height === 0 && ++i < 20) {
triggerSetup();
} else {
const y = track.location.midile - height / 2;
const y = track.location.middle - height / 2;
if (y + height > this.container.height) return;
dm._updatePosition({ y });
setup();
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface ManagerOptions extends EngineOptions {

export interface Location {
top: number;
midile: number;
middle: number;
bottom: number;
}

Expand Down

0 comments on commit c9e5dac

Please sign in to comment.