Skip to content

Commit

Permalink
Added a new duplicateCount parameter to control the number of duplica…
Browse files Browse the repository at this point in the history
…tes (#179)

* Added a new duplicateCount parameter to control the number of duplicates

* Fix tabs

---------

Co-authored-by: Mark Young <[email protected]>
  • Loading branch information
tip2tail and Mark Young authored Jan 6, 2025
1 parent de6ce1e commit 6e6ac2e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Options:
- **delayBeforeStart** Time in milliseconds before the marquee starts animating. Default: ```1000```
- **direction** Direction towards which the marquee will animate ```'left' / 'right' / 'up' / 'down'```. Default: ```'left'```. Todo: need to change this to ```ltr/rtl``` etc
- **duplicated** Should the marquee be duplicated to show an effect of continuous flow. Use this only when the text is shorter than the container. Default: ```false```
- **duplicateCount** The number of duplicates to be added. Default: ```1```
- **duration** Duration in milliseconds in which you want your element to travel. Default: ```5000```.
- **speed** Speed 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 per second.
- **gap** Gap in pixels between the tickers. Will work only when the ```duplicated``` option is set to ```true```. Default: ```20```. Note: ```20``` means ```20px``` so no need to use ```'20px'``` as the value.
Expand Down Expand Up @@ -110,7 +111,9 @@ $('.marquee').marquee({
//'left' or 'right'
direction: 'left',
//true or false - should the marquee be duplicated to show an effect of continues flow
duplicated: true
duplicated: true,
//duplicate the message three times
duplicateCount: 3
});
```

Expand Down Expand Up @@ -229,6 +232,9 @@ $(window).load(function() {
Updates:
-----------
**Update (2 Jan 2025):**
Added the `duplicateCount` parameter to control the number of duplicates that will be added when `duplicate` is `true`. Thanks to @tip2tail.
**Update (8 Mar 2016):**
Now plugin have new option: **startVisible** The marquee will be visible in the start if set to `true`. Thanks to @nuke-ellington 👍
Expand Down
10 changes: 9 additions & 1 deletion jquery.marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@
});

if (o.duplicated) {
$el.clone(true).appendTo($this);
if (o.duplicateCount <= 0) {
// If duplication enabled then the duplicate count must be a positive number
o.duplicateCount = 1;
}
for (let duplicateLoop = 0; duplicateLoop < o.duplicateCount; duplicateLoop++) {
$el.clone(true).appendTo($this);
}
}

// wrap both inner elements into one div
Expand Down Expand Up @@ -482,6 +488,8 @@
direction: 'left',
// true or false - should the marquee be duplicated to show an effect of continues flow
duplicated: false,
// number of duplicates to create, default is 1
duplicateCount: 1,
// duration in milliseconds of the marquee in milliseconds
duration: 5000,
// Speed allows you to set a relatively constant marquee speed regardless of the width of the containing element. Speed is measured in pixels per second.
Expand Down
Loading

0 comments on commit 6e6ac2e

Please sign in to comment.