Socket
Socket
Sign inDemoInstall

reeller

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reeller

Flexible, powerful and modern library for creating the running horizontal blocks effect, also known as ticker or the «marquee effect».


Version published
Weekly downloads
202
decreased by-34.63%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Cuberto Reeller

NPM Version Licence Bundle file size Bundle file size (gzip) NPM Downloads GitHub Workflow Status

Flexible, powerful and modern library for creating the running horizontal blocks effect, also known as ticker or the «marquee effect».

The library uses GSAP, IntersectionObserver and ResizeObserver to achieve the best performance results.

⚠️ Notice: This library is currently in beta.

Dependencies

GSAP v3 (https://greensock.com/gsap/)

Quick start

Install from NPM

Reeller requires GSAP library to work.

npm install gsap --save
npm install reeller --save

Import GSAP, Reeller and initialize it:

import Reeller from 'reeller';
import gsap from 'gsap';

Reeller.registerGSAP(gsap);

const reeller = new Reeller({
    container: '.my-reel',
    wrapper: '.my-reel-wrap',
    itemSelector: '.my-reel-item',
    speed: 10,
});

Use from CDN

If you don't want to include Reeller files in your project, you can use library from CDN:

<script src="https://unpkg.com/reeller@0/dist/reeller.min.js"></script>

Reeller requires GSAP to work. You need to import it above the Reeller if you didn't have it before:

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
<script src="https://unpkg.com/reeller@0/dist/reeller.min.js"></script>
<script>
    var reeller = new Reeller.Reeller({
        container: '.my-reel',
        wrapper: '.my-reel-wrap',
        itemSelector: '.my-reel-item',
        speed: 10,
    });
</script>

Note: All modules (Reeller, Filler, ScrollerPlugin) will be imported into Reeller namespace when using from CDN, so you must use a prefix.

Options

You can configure Reeller via options.

The following options with defaults is available:

const reeller = new Reeller({
    container: null,
    wrapper: null,
    itemSelector: null,
    cloneClassName: '-clone',
    speed: 10,
    ease: 'none',
    initialSeek: 10,
    loop: true,
    paused: true,
    reversed: false,
    autoStop: true,
    autoUpdate: true,
    clonesOverflow: true,
    clonesFinish: false,
    clonesMin: 0,
});
OptionTypeDefaultDescription
containerstring | HTMLElementnullRequired. Container element or selector.
wrapperstring | HTMLElementnullRequired. Inner element or selector.
itemSelectorstringnullRequired. Items CSS selector.
cloneClassNamestring-cloneClass name of the new clones.
speednumber10Movement speed.
easestring'none'Timing function. See gsap easing.
initialSeeknumber10Initial seek of timeline.
loopbooleantrueLoop movement.
pausebooleantrueInitialize in paused mode.
reversedbooleanfalseReverse mode.
autoStopbooleantrueUse IntersectionObserver to auto stop movement.
autoUpdatebooleantrueUse ResizeObserver to auto update clones number.
clonesOverflowbooleantrueCreate artificial overflow with clones.
clonesFinishbooleanfalseBring the cycle of clones to an end.
clonesMinboolean0Minimum number of clones.
pluginsObjectnullOptions for plugins. See Plugins section.

API

Methods

MethodDescription
reeller.resume()Resumes movement.
reeller.pause()Pauses movement.
reeller.reverse([reversed=true])Set reversed moving.
reeller.invalidate()Refresh GSAP Timeline.
reeller.update()Calculates and sets the number of clones and update movement position.
reeller.refresh(update=true)Fully refresh and update all clones and position. Use this only after adding or removing original items.
reeller.destroy(removeClones=true)Destroy Reeller instance, detach all observers and remove clones.
Reeller.registerGSAP(gsap)Static method to register the gsap library.
Reeller.use(...plugins)Static method to register a plugins.

Properties

PropertyTypeDescription
reeller.pausedbooleanIndicates that the movement is stopped.
reeller.tlTimelineGSAP Timeline.
reeller.fillerFillerInner Filler instance. See Filler section.
reeller.optionsReellerOptionsCurrent Reeller options.
reeller.pluginObjectInitialized plugins.

Events

Reeller comes with a useful events you can listen. Events can be assigned in this way:

reeller.on('update', () => {
    console.log('Reeller update happened!');
});

You can also delete an event that you no longer want to listen in these ways:

reeller.off('update');
reeller.off('update', myHandler);
EventArgumentsDescription
update(reeller, calcData)Event will be fired after update.
refresh(reeller)Event will be fired after refresh.
destroy(reeller)Event will be fired after destroy.

Plugins

Reeller support plugins to extend functionality.

At this moment there is only one plugin that comes with the official package: ScrollerPlugin.

This plugin allows you to attach movement to the scroll:

import {Reeller, ScrollerPlugin} from 'reeller';
import gsap from 'gsap';

Reeller.registerGSAP(gsap);
Reeller.use(ScrollerPlugin);

const reeller = new Reeller({
    container: '.my-reel',
    wrapper: '.my-reel-wrap',
    itemSelector: '.my-reel-item',
    speed: 10,
    plugins: {
        scroller: {
            speed: 1,
            multiplier: 0.5,
            threshold: 1,
        },
    },
});

The following options of ScrollerPlugin is available:

OptionTypeDefaultDescription
speednumber1Movement and inertia speed.
multipliernumber0.5Movement multiplier.
thresholdnumber1Movement threshold.
easestring'expo.out'Timing function. See gsap easing.
overwritebooleantrueSee gsap overwrite modes.
bothDirectionbooleantrueAllow movement in both directions.
reversedbooleanfalseReverse scroll movement.
stopOnEndbooleanfalseStop movement on end scrolling.
scrollProxyfunctionnullA function that returns the scroll position. Can be used in cases with custom scroll.

In cases with using of custom scroll libraries (e.g. smooth-scrollbar), you can use the scrollProxy option to return the current scroll position:

import Scrollbar from 'smooth-scrollbar';
import {Reeller, ScrollerPlugin} from 'reeller';
import gsap from 'gsap';

Reeller.registerGSAP(gsap);
Reeller.use(ScrollerPlugin);

const scrollbar = Scrollbar.init(document.querySelector('#my-scrollbar'));

const reeller = new Reeller({
    container: '.my-reel',
    wrapper: '.my-reel-wrap',
    itemSelector: '.my-reel-item',
    speed: 10,
    plugins: {
        scroller: {
            speed: 1,
            multiplier: 0.5,
            threshold: 1,
            scrollProxy: () => scrollbar.scrollTop,
        },
    },
});

Filler

Reeller library works on top of the Filler module. This is a separate tool for automatically calculating the number of clones and filling the container with them.

You can use only Filler (without Reeller) if you need to fill the whole space with clones, without movement, animations and GSAP:

import {Filler} from 'reeller';

const filler = new Filler({
    container: '.my-container',
    itemSelector: '.-my-item',
    cloneClassName: '-clone',
});

Options

OptionTypeDefaultDescription
containerstring | HTMLElementnullRequired. Container element or selector.
itemSelectorstringnullRequired. Items CSS selector.
wrapperstring | HTMLElementnullInner element or selector.
cloneClassNamestring'-clone'Class name of the new clones.
autoUpdatebooleantrueUse ResizeObserver to auto update clones number.
clonesOverflowbooleanfalseCreate artificial overflow with clones.
clonesFinishbooleanfalseBring the cycle of clones to an end.
clonesMinbooleanfalseMinimum number of clones.

Methods

MethodDescription
filler.addClones(count, offset=0)Creates and adds clones to end in the desired number from given offset.
filler.removeClones(count)Removes the desired number of clones from the end.
filler.setClonesCount(count)Sets the desired number of clones.
filler.getCalcData()Returns a calculated data object (number of clones, widths, etc.)
filler.update()Calculates and sets the number of clones.
filler.refresh(update=true)Fully refresh and update all clones. Use this only after adding or removing original items.
filler.destroy(removeClones=true)Destroy Filler instance, detach all observers and remove clones.

Properties

PropertyTypeDescription
filler.containerHTMLElementContainer element.
filler.wrapperHTMLElementInner element.
filler.itemArray.<HTMLElement>Items array.
filler.calcDataObjectCalculated data (number of clones, widths, etc.).
filler.optionsReellerOptionsCurrent Filler options.

Events

EventArgumentsDescription
update(filler, calcData)Event will be fired after update.
refresh(filler)Event will be fired after refresh.
destroy(filler)Event will be fired after destroy.

Examples of use

  • Cuberto: Leading digital agency.
  • Potion: Video email for top sales professionals.
  • Weltio: More ways to grow your money.
  • WorkJam: Drive Employee Engagement.
  • Spendwisor: Make your shopping easier.
  • Sleepiest: The Sleepiest App.
  • Perform: Unlock workout superpowers.

License

The MIT License (MIT)

Keywords

FAQs

Last updated on 09 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc