Skip to content

Commit

Permalink
only ask for a new item when it becomes needed, not while it is needed
Browse files Browse the repository at this point in the history
Without this change it asks constantly whilst there is something on the marquee, otherwise it stops, which is inconsistent
  • Loading branch information
tjenkinson committed Mar 4, 2023
1 parent cdfa4bf commit ee2606b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Marquee {
});

this._waitingForItem = true;
this._askedForItem = true;
this._nextItemWouldBeTouching = startOnScreen;
this._rate = rate;
this._lastEffectiveRate = rate;
Expand Down Expand Up @@ -142,6 +143,7 @@ export class Marquee {
throw new Error('Item already exists.');
}
this._waitingForItem = false;
this._askedForItem = false;
this._pendingItem = new Item($el, this._direction, metadata, () =>
this._tickOnRaf()
);
Expand Down Expand Up @@ -393,7 +395,8 @@ export class Marquee {

this._updateWindowInverseSize();

if (requireNewItem) {
if (requireNewItem && !this._askedForItem) {
this._askedForItem = true;
let nextItem;
this._onItemRequired.some((cb) => {
return deferException(() => {
Expand Down

0 comments on commit ee2606b

Please sign in to comment.