Home
Softono
vue-marquee-text-component

vue-marquee-text-component

Open source MIT Vue
480
Stars
46
Forks
6
Issues
9
Watchers
2 years
Last Commit

About vue-marquee-text-component

Vue Marquee Text Component is a lightweight, performance-optimized Vue.js plugin designed to create smooth scrolling text effects. It leverages CSS GPU animation techniques to ensure high-frame-rate rendering without causing page layout thrashing. The component supports both Vue 2 and Vue 3 environments and can be registered globally or locally within individual views. Key features include configurable animation duration, the ability to repeat content to form a seamless loop, and built-in controls for pausing or reversing the scroll direction. It is particularly useful for displaying long headlines on narrow screens, music player track titles, news tickers, or stock price updates. Users can easily set a repeat count to duplicate short text for continuous flow. To handle dynamic content changes, such as updating the scroll text inside a music player, the component requires a unique key prop to force a reload and reset the animation state. Installation is available via npm or yarn, allowing developers to import

Platforms

Web Self-hosted

Languages

Vue

vue-marquee-text-component

[CSS GPU Animation] Marquee Text for vuejs

npm license npm

Demo

Demo here

Install

Vue 3 (master) | Vue 2 (v1)

npm install vue-marquee-text-component or yarn add vue-marquee-text-component

Usage

The most common use case is to register the component globally.

// in your main.js or similar file
import Vue from 'vue'
import MarqueeText from 'vue-marquee-text-component'

Vue.component('marquee-text', MarqueeText)

Alternatively you can do this to register the components:

// HelloWorld.vue
import MarqueeText from 'vue-marquee-text-component'

export default {
  name: 'HelloWorld',
  components: {
    MarqueeText
  }
}

On your page you can now use html like this:

<!-- simple marquee text -->
<marquee-text>
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna.
</marquee-text>

<!-- short text need more duplicates -->
<marquee-text :repeat="10">
  Short text =(
</marquee-text>

<!-- slow duration -->
<marquee-text :duration="30">
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna.
</marquee-text>

Props

Prop Type Default Description
duration Number 15 Animation Duration
repeat Number 2 Number of repeat the Slot (It's important for to short content)
paused Boolean false The property specifies whether the animation is running or paused
reverse Boolean false Set animation-direction to reverse

Important information for dynamic content

If you change the content you need reload the component. For this use property :key see more

<!-- parse a unique key for reload the component  -->
<marquee-text :key="currentTrack.id">
  {{ currentTrack.title }}
</marquee-text>

Build Setup

yarn install
yarn run serve
yarn run build
yarn run lint