Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
dynamic-marquee
Advanced tools
A small library for creating marquees. No dependencies!
Features:
A loop()
helpers function is also provided which makes creating a carousel with looping content simple.
npm install --save dynamic-marquee
import { Marquee } from 'dynamic-marquee';
or
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/dynamic-marquee@1"></script>
<script type="text/javascript">
const Marquee = dynamicMarquee.Marquee;
</script>
thanks to jsDelivr.
const marquee = new Marquee(document.getElementById('marquee'));
const marquee = new Marquee(document.getElementById('marquee'), {
rate: 20, // 20 pixels/s downwards
upDown: true // downwards instead of to the right
});
You can add DOM elements, or just a string (which will automatically be wrapped in a div).
const $item = document.createElement('div');
$item.textContent = 'testing123';
marquee.appendItem($item);
You are only allowed to append an item when there is room. You can check this like so:
if (marquee.isWaitingForItem()) {
marquee.appendItem($item);
}
You can be notified when an item is required with
marquee.onItemRequired(() => {
// for convenience if you have an item ready to go you can just return it
// in place of `marquee.appendItem($item);`
return $item;
});
You can change the rate at any time, and set to 0 to pause.
marquee.setRate(-20);
To remove all items call
marquee.clear();
You can be notified when an item has been removed with:
marquee.onItemRemove(($el) => {
// $el has just been removed
});
You can be notified when the scroller is empty with:
marquee.onAllItemsRemoved(() => {
//
});
You can check at any time with:
marquee.getNumItems();
A loop()
function is provided for making looping content simple.
You provide an array of functions which return a DOM element, or string for that item. You can update this on the fly by calling the provided update()
method.
const $marquee = document.getElementById('marquee');
const marquee = new Marquee($marquee);
const control = loop(marquee, [
() => 'item 1',
() => 'item 2'
]);
// later
control.update([
() => 'new item 1',
() => 'new item 2'
])
See "demo.html".
FAQs
A small library for creating marquees.
The npm package dynamic-marquee receives a total of 163 weekly downloads. As such, dynamic-marquee popularity was classified as not popular.
We found that dynamic-marquee demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.