New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

na-danmaku

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

na-danmaku

一个弹幕播放组件

unpublished
latest
npmnpm
Version
0.0.2
Version published
Maintainers
0
Created
Source

Snail Danmaku

一个简洁的弹幕动画组件,不提供太多配置,只提供最基础的功能。

示例

<template>
  <div style="display: flex; flex-direction: column; align-items: center">
    <Danmaku
      ref="danma"
      :paused="paused"
      style="
        width: 600px;
        height: 450px;
        background-color: black;
        overflow: hidden;
      ">
      <template #="danmakuItem">
        <div
          @mouseenter="toggleItemPaused(danmakuItem)"
          @mouseleave="toggleItemPaused(danmakuItem)"
          style="cursor: pointer">
          {{ danmakuItem.text }}
        </div>
      </template>
    </Danmaku>
    <div class="danma-controls">
      <select v-model="danmaItem.type">
        <option value="move">move</option>
        <option value="top">top</option>
        <option value="bottom">bottom</option>
      </select>
      <input type="color" v-model="danmaItem.color" />
      <input v-model="danmaItem.text" />
      <button @click="draw">发送</button>
      <button @click="togglePaused">{{ paused ? "播放" : "暂停" }}</button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import Danmaku from "snail-danmaku";
import type { DanmakuItem } from "@/_interface";

const danma = ref<InstanceType<typeof Danmaku>>();

const paused = ref(false);
const togglePaused = () => {
  paused.value = !paused.value;
};
const toggleItemPaused = (da: DanmakuItem) => {
  if (!da.$el) return;
  if (da.$el.style.animationPlayState === "paused") {
    da.$el.style.animationPlayState = "running";
  } else {
    da.$el.style.animationPlayState = "paused";
  }
};

const danmaItem = ref<DanmakuItem>({
  text: "",
  type: "move",
  color: "#ffffff",
});
const draw = () => {
  const item = { ...danmaItem.value };
  danma.value?.draw([item]);
};
</script>

Keywords

sanil

FAQs

Package last updated on 10 Oct 2024

Related posts