1.1.2 • Published 2 years ago

vanilla-marquee v1.1.2

Weekly downloads
202
License
ISC
Repository
github
Last release
2 years ago

vanilla-marquee

An es5 vanilla-js implementation of jQuery.marquee

Installation

npm i vanilla-marquee

Usage

import marquee from 'vanilla-marquee'

new marquee( element, {
  options
})

Demo

https://mattiacoll.github.io/vanilla-marquee-site/


Differences between this plugin and jQuery.marquee

Although this plugin can be a drop in replacment for the jQuery plugin there are some caveats, which may be deal breaking:

  • allowCss3Support and easing options have been removed (all animations use the @keyframe implementation)
  • pauseOnCycle option has been removed, since it was available only when allowCss3Support was set to false
  • no IE and dead browser support, since we are in $currentYear I don't think it's necessary
  • this module is not transpiled for old browsers, you can transpile it yourself: example with rollup and babel
babel({
  babelHelpers: 'bundled',
  exclude:      '/node_modules/',
  include: [
    'src/**', // src folder
    /node_modules\/.+(vanilla-marquee|matt-utils)/,
  ]
}),
  • the methods can only be called with instance.method(), in the jQuery version they can be called using $( selector ).marquee( 'methodName' )
  • events are fired on the selector rathen than the instance

Options

OptionDefaultDescription
css3easing'linear'a css3 transtion timing
delayBeforeStart1000Time in ms before the marquee starts animating
direction'left'Direction towards which the marquee will animate 'left', 'right', 'up', 'down'
duplicatedfalseShould the marquee be duplicated to show an effect of continuous flow. Use this only when the text is shorter than the container
duration5000Duration in ms in which you want your element to travel
speed0Speed will override duration. Speed allows you to set a relatively constant marquee speed regardless of the width of the containing element. Speed is measured in pixels/second
gap20Gap in pixels between the tickers. Will work only when the duplicated option is set to true. Note: 20 means 20px so no need to use '20px' as the value.
pauseOnHoverfalsePause the marquee on hover.
startVisiblefalseThe marquee will be visible from the start if set to true.
recalcResizefalseShould the marquee be updated on resize.

Methods

NameDescription
pauseTo pause the marquee at any time.
resumeTo resume the marquee after being paused previously.
toggleTo toggle between pause and resume methods.
destroyTo remove the marquee and all attached events from your element. This method is useful if you are loading/changing the data using Ajax or just another string. You can combine this with the finished event so you can have the marquee show some data and as soon as it finishes showing that, you can destroy it, change the html and then apply the plugin again.
refreshRecalcs the marquee size and position. Works like the recalcResize but is triggered manually instead of on window resize.

Events:

NameDescription
beforeStartingEvent will be fired on the element before animation starts.
finishedEvent will be fired on the element on each iteration of the animation when it finishes.
pausedEvent will be fired on the element when the animation is paused.
resumedEvent will be fired on the element when the animation is resumed.

How to contribute

Prerequisites

Making changes

  • Edit source code in the src folder.
  • Once ready, compile the package with npm run rl.
1.1.2

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago