npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amaoaaaaa/v-text-ellipsis

v0.2.2

Published

Vue 3 指令,文本溢出省略号并支持 GSAP 滚动显示全文

Readme

@amaoaaaaa/v-text-ellipsis

一个 Vue 3 指令,给文本添加溢出省略号效果,并在鼠标悬停时使用 GSAP 滚动显示全文。


特性

  • 文本超出容器宽度时显示省略号 (...)。
  • 鼠标悬停时,文本平滑滚动展示完整内容。
  • 支持按需注册指令或全局注册插件。

安装

npm install @amaoaaaaa/v-text-ellipsis

注意:vuegsap 为 peer dependencies,需要在项目中已安装。


使用方法

1. 全局注册插件

import { createApp } from "vue";
import App from "./App.vue";
import TextEllipsis from "@amaoaaaaa/v-text-ellipsis";

const app = createApp(App);
app.use(TextEllipsis);
app.mount("#app");

在组件中即可使用:

<template>
  <div v-text-ellipsis style="width: 200px;">
    这是一段很长的文本,鼠标悬停时会滚动显示完整内容。
  </div>
</template>

2. 按需注册指令

import { createApp } from "vue";
import App from "./App.vue";
import { vTextEllipsis } from "@amaoaaaaa/v-text-ellipsis";

const app = createApp(App);
app.directive("text-ellipsis", vTextEllipsis);
app.mount("#app");

3. 在组件内部注册指令

setup 语法糖,导入直接就能在 template 中用

<script lang="ts" setup>
import { vTextEllipsis } from "@amaoaaaaa/v-text-ellipsis";
</script>

指令参数

  • v-text-ellipsis="true|false"

    • true:启用文本溢出省略和滚动效果
    • false:禁用效果

类型拓展

拓展 Vue 全局属性

// types/vue-shim.d.ts
import 'vue';
import { vTextEllipsis } from "@amaoaaaaa/v-text-ellipsis";

declare module '@vue/runtime-core' {
    export interface ComponentCustomProperties {
        /**
         * 自定义指令:v-text-ellipsis
         * @description 给元素添加文本溢出显示省略号,鼠标移入时内容滚动的效果
         */
        vTextEllipsis: typeof vTextEllipsis; 
    }
}

注意事项

  • 该指令依赖 gsap 实现滚动动画。
  • 请确保元素有固定宽度,否则滚动效果可能不明显。