1.0.9 • Published 3 months ago

vanilla-infinite-marquee v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Vanilla Infinite Marquee

npm npm downloads npm license

Installation

If you're using npm, in the command prompt run:

npm install vanilla-infinite-marquee

If you're using yarn, run:

yarn add vanilla-infinite-marquee

Demo

Usage

To use the component, first import CSS styles into your CSS/SCSS file:

@import 'node_modules/vanilla-infinite-marquee/infinite-marquee.css'; //OR
@import 'node_modules/vanilla-infinite-marquee/infinite-marquee.scss';

Basic HTML Input

<div class="marquee-container">
    <p>Horizontal Marquee Item 1</p>
    <p>Horizontal Marquee Item 2</p>
</div>

import InfiniteMarquee into your JS file:

import InfiniteMarquee from 'vanilla-infinite-marquee';

new InfiniteMarquee({
	element: '.marquee-container',
	speed: 25000,
	smoothEdges: true,
	direction: 'right',
	gap: '15px',
	duplicateCount: 2,
	mobileSettings: {
		direction: 'top',
		speed: 20000
	},
	on: {
		beforeInit: () => {
			console.log('Not Yet Initialized');
		},

		afterInit: () => {
			console.log('Initialized');
		}
	}
});

Options

OptionTypeDefaultDescription
elementstring, NodenullSelector
directionstring"left"Direction of Marquee animation, "left", "right", "top", "bottom"
spaceBetweenstring"0px"Gaps to be used for "left" or "right" direction ONLY
gapobject{vertical: "5px", "horizontal: "0px" }Gaps to be used for "top" or "bottom" direction ONLY
speednumber10000Speed of animation in ms
smoothEdgesbooleanfalseWhether to smooth covered edges or not
fullContainerbooleantrueFill the full width of container, for "left" or "right" direction ONLY
pauseOnHoverbooleanfalsePause animation on hover
destroyOnDesktopbooleanfalseDestroy Marquee structure and animation on "Desktop"
destroyOnMobilebooleanfalseDestroy Marquee structure and animation on "Mobile"
debuggingbooleanfalseDebug in console each event of Marquee lifecycle
elementClassstringmarquee-containerClass of Container that will be used to destroy Marquee
duplicateCountnumber1Count of marquee be duplicated to show an effect of continuous flow
breakpointSizenumber991.8"max-width" breakpoint for responsive devices, accepted only single breakpoint
mobileSettingsobject{}Responsive options (works only for spaceBetween, gap, speed and direction properties)
onobject{}Object to contain callback functions below
beforeInitfunctionnullA callback function that invokes before marquee initialization
afterInitfunctionnullA callback function that invokes after marquee initialization
pauseAnimationfunctionnullA callback function that invokes on Pause
resumeAnimationfunctionnullA callback function that invokes on Resume