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 🙏

© 2024 – Pkg Stats / Ryan Hefner

css-marquee

v0.2.1

Published

No dependencies javascript marquee based on CSS animations.

Downloads

1

Readme

CSSMarquee

CSSMarquee is a Javascript no dependencies javascript marquee based on CSS animations.

Core features of CSSMarquee are:

Installation

CSSMarquee is registered as a package on npm. This is the recomended way of downloading it. You can install the latest version of CSSMarquee and its dependencies with the npm CLI command:

npm install css-marquee

As an alternative you can download from github.

Usage

cssMarqueExample.html

<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="style.css">
  <script src="cssMarquee.min.js"></script>
  <title>CSSMarquee</title>
</head>

<body>
    <p id="myMarquee" class="marquee">Default text</p>
    
    <script>
        var myMarquee = new CSSMarquee({
            id: 'myMarquee',
            text: 'CSSMarquee: no dependencies javascript marquee based on CSS animations.',
            speed: 20,
            pauseOnMouseEnter: true,
            playOnMouseLeave: true
        });
    </script>
</body>

</html>

Where cssMarquee.min.js is the minimized version of cssMarquee.

Available configuration parameters are:

  • id. The id of the DOM element.
  • element. The DOM element. It is required to set element or id. If both are set elementis used.
  • text. The text in the marque. If it is not set CSSMarquee uses the text in the DOM element. It is required to set text or some text in the DOM element.
  • speed. The number of seconds to complete one iteration. Default is 15.
  • pauseOnMouseEnter. If it is true the animation will be paused when a mouseenter event is triggered.
  • playOnMouseLeave. If it is true the animation will be resumed when a mouseleave event is triggered.
  • animation. The CSS animation to use. Default is marqueeTextIndent {0}s linear infinite. See the next chapter for more details.

Available methods for CSSMarquee instances are:

  • pause(). Pauses the animation.
  • play(). Resumes the animation.
  • updateText( newText ). Updates the text.
  • destroy( removeText ). Stops the animation and remove all listeners. If removeText removes the text of the marquee.

Go to test page to see CSSMarquee in action!

Customizing the CSS animation

If you want to fully customize the CSS animation keep on reading this!

Default animation is marqueeTextIndent {0}s linear infinite. You can customize it with the built in keyframes CSS animations or define a new one. The {0} part is replaced by CSSMarquee with the speed configuration parameter.

CSSMarquee includes 4 keyframes CSS animations in the style.css file:

  • marqueeTextIndent (used in default animation). Animates the text-indent property. Animation is from right to left.
  • marqueeTextIndentReverse. Animates the text-indent property. Animation is from left to right.
  • marqueeTranslateX. Uses translateX to animate. Animation is from right to left.
  • marqueeTranslateXReverse. Uses translateX to animate. Animation is from left to right.

The definitions of both in the style.css file are:

@keyframes marqueeTextIndent {
    0%   { text-indent: 100% }
    100% { text-indent: var(--marquee-text-size) }
}

@keyframes marqueeTextIndentReverse {
    0%   { text-indent: var(--marquee-text-size)  }
    100% { text-indent: 100% }
}

@keyframes marqueeTranslateX {
    0%   { transform: translateX( 100% ) }
    100% { transform: translateX( var(--marquee-text-size) ) }
}

@keyframes marqueeTranslateXReverse {
    0%   { transform: translateX( var(--marquee-text-size) ) }
    100% { transform: translateX( 100% ) }
}

The --marquee-text-size CSS variable is set by CSSMarquee. Its value depends on the length of the text to animate.

Of course, if you are not going to use one of them you do not need to include it in you CSS files.

Another option is to define a new keyframes CSS animation in one of your CSS files and customize the animation option to use it.

License

LGPL