dynamic-marquee
Advanced tools
Comparing version 2.3.10 to 2.3.11
@@ -486,2 +486,4 @@ (function (global, factory) { | ||
this._justReversedRate = !this._justReversedRate; | ||
// flip to false which will cause a new item to be asked for if necessary | ||
this._waitingForItem = this._askedForItem = false; | ||
} | ||
@@ -491,9 +493,4 @@ this._rate = rate; | ||
this._lastEffectiveRate = rate; | ||
if (!this._items.length) { | ||
this._waitingForItem = true; | ||
} | ||
} else { | ||
this._waitingForItem = false; | ||
} | ||
this._tick(this._waitingForItem); | ||
this._tick(true); | ||
} | ||
@@ -516,2 +513,3 @@ }, { | ||
_this._waitingForItem = true; | ||
_this._askedForItem = true; | ||
_this._nextItemWouldBeTouching = false; | ||
@@ -687,3 +685,3 @@ _this._updateWindowInverseSize(); | ||
var newItemWouldBeTouching = _this6._nextItemWouldBeTouching; | ||
_this6._nextItemWouldBeTouching = null; | ||
_this6._nextItemWouldBeTouching = false; | ||
var nextItemTouching = null; | ||
@@ -693,5 +691,5 @@ | ||
_this6._items.reduce(function (newOffset, item) { | ||
if (newOffset !== null && item.offset < newOffset) { | ||
// the size of the item before has increased and would now be overlapping | ||
// this one, so shuffle this one along. | ||
if (newOffset !== null && | ||
// size of the item before has increased and would be overlapping | ||
item.offset < newOffset) { | ||
item.offset = newOffset; | ||
@@ -706,3 +704,3 @@ } | ||
var neighbour = last(_this6._items); | ||
var offsetIfWasTouching = neighbour ? neighbour.offset + neighbour.item.getSize() : _this6._windowOffset; | ||
var offsetIfWasTouching = neighbour ? neighbour.offset + neighbour.item.getSize() : _this6._windowOffset + containerSize; | ||
_this6._items = [].concat(_toConsumableArray(_this6._items), [{ | ||
@@ -720,3 +718,3 @@ item: _this6._pendingItem, | ||
var _neighbour = first(_this6._items); | ||
var _offsetIfWasTouching = _neighbour ? _neighbour.offset - _this6._pendingItem.getSize() : _this6._windowOffset + containerSize - _this6._pendingItem.getSize(); | ||
var _offsetIfWasTouching = _neighbour ? _neighbour.offset - _this6._pendingItem.getSize() : _this6._windowOffset - _this6._pendingItem.getSize(); | ||
_this6._items = [{ | ||
@@ -733,20 +731,24 @@ item: _this6._pendingItem, | ||
} | ||
// add a buffer on the side to make sure that new elements are added before they would actually be on screen | ||
var buffer = renderInterval / 1000 * Math.abs(_this6._rate); | ||
var requireNewItem = _this6._waitingForItem; | ||
if (!_this6._waitingForItem && _this6._items.length /* there should always be items at this point */) { | ||
var firstItem = first(_this6._items); | ||
var lastItem = last(_this6._items); | ||
var touching = _this6._lastEffectiveRate <= 0 ? lastItem : firstItem; | ||
if (_this6._lastEffectiveRate <= 0 && lastItem.offset + lastItem.item.getSize() - _this6._windowOffset <= containerSize + buffer || _this6._lastEffectiveRate > 0 && firstItem.offset - _this6._windowOffset > -1 * buffer) { | ||
_this6._waitingForItem = requireNewItem = true; | ||
// if an item is appended immediately below, it would be considered touching | ||
// the previous if we haven't just changed direction. | ||
// This is useful when deciding whether to add a separator on the side that enters the | ||
// screen first or not | ||
nextItemTouching = justReversedRate ? null : { | ||
$el: touching.item.getOriginalEl(), | ||
metadata: touching.item.getMetadata() | ||
}; | ||
if (!_this6._waitingForItem && _this6._rate !== 0) { | ||
if (_this6._items.length) { | ||
// add a buffer on the side to make sure that new elements are added before they would actually be on screen | ||
var buffer = renderInterval / 1000 * Math.abs(_this6._rate); | ||
if (!_this6._waitingForItem && _this6._rate !== 0) { | ||
var firstItem = first(_this6._items); | ||
var lastItem = last(_this6._items); | ||
var touching = _this6._lastEffectiveRate <= 0 ? lastItem : firstItem; | ||
if (_this6._lastEffectiveRate <= 0 && lastItem.offset + lastItem.item.getSize() - _this6._windowOffset <= containerSize + buffer || _this6._lastEffectiveRate > 0 && firstItem.offset - _this6._windowOffset > -1 * buffer) { | ||
_this6._waitingForItem = true; | ||
// if an item is appended immediately below, it would be considered touching | ||
// the previous if we haven't just changed direction. | ||
// This is useful when deciding whether to add a separator on the side that enters the | ||
// screen first or not | ||
nextItemTouching = !justReversedRate ? { | ||
$el: touching.item.getOriginalEl(), | ||
metadata: touching.item.getMetadata() | ||
} : null; | ||
} | ||
} | ||
} else { | ||
_this6._waitingForItem = true; | ||
} | ||
@@ -770,3 +772,3 @@ } | ||
_this6._updateWindowInverseSize(); | ||
if (requireNewItem && !_this6._askedForItem) { | ||
if (_this6._waitingForItem && !_this6._askedForItem) { | ||
_this6._askedForItem = true; | ||
@@ -773,0 +775,0 @@ var nextItem; |
{ | ||
"name": "dynamic-marquee", | ||
"version": "2.3.10", | ||
"version": "2.3.11", | ||
"description": "A small library for creating marquees.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/dynamic-marquee.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52981
911