Seamless Content Scrolling With jQuery Marquee.js

File Size: 5.47 KB
Views Total: 626
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Seamless Content Scrolling With jQuery Marquee.js

marquee is a tiny jQuery plugin that allows you to implement infinite horizontal or vertical scrolling for HTML lists.

Ideal for displaying extensive data such as breaking news, stock quotes, and product images, this plugin allows content to move fluidly across the screen in four possible directions: left, right, up, and down.

How to use it:

1. Add the jquery.marquee.min.js script to the page after you've loaded the latest jQuery library.

<script src="jquery.min.js"></script>
<script src="jquery.marquee.min.js"></script>

2. Apply the marquee.js to an HTML list by calling the marquee function:

<div class="marquee-wrapper" id="example">
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    ... more items here ...
  </ul>
</div>
$(function(){ 
  $("#example").marquee();
});

3. Customize the scrolling behavior with these options:

$("#example").marquee({

  // 'left', 'right', 'up', 'down'
  direction: 'left',

  // Lower value = faster scroll
  speed: 20,

  // Continuous scrolling 
  loop: true,

  // Pause on mouse hover
  pausehover: false,

  // Spacing between items
  spaceBetween: 10

});

How it works:

marquee.js works by cloning the original content and appending it to create a continuous flow. It uses JavaScript to manipulate the scroll position of the container element. The scrolling effect is achieved through a timer that updates the scroll position at regular intervals.

The plugin handles different scrolling directions by adjusting the scroll position accordingly. For left and up directions, it increases the scroll position. For right and down directions, it decreases the scroll position.

When the scroll position reaches the end of the content, it resets to the beginning, creating the illusion of infinite scrolling. The plugin also checks if the content is longer than the container to determine if scrolling is necessary.

Users can customize the plugin's behavior through various options. These include setting the scrolling speed, enabling or disabling looping, adding pause on hover functionality, and adjusting the space between scrolling items.


This awesome jQuery plugin is developed by th74100. For more Advanced Usages, please check the demo page or visit the official website.