From a10e4ca0da2119e7b390e8cc25a6fdff3b51b3e0 Mon Sep 17 00:00:00 2001 From: KelseyCooper Date: Thu, 18 Feb 2021 15:30:34 -0800 Subject: [PATCH 1/2] Account for Lorenza offset --- js/flickity.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/flickity.js b/js/flickity.js index fe4d45c..2f42608 100644 --- a/js/flickity.js +++ b/js/flickity.js @@ -761,6 +761,13 @@ proto.checkVisibility = function() { var viewportX = this.viewport.getBoundingClientRect().x; var viewportWidth = this.viewport.offsetWidth; + // Lorenza pulls content that should be out of the viewport in to + // force slides on either side of the viewport. We need to offset + // the viewport by the maximum amount it can be pulled in 4px. + if (this.options.wrapAround) { + viewportWidth = viewportWidth - 4; + } + this.cells.forEach(function (cell) { var cellX = cell.element.getBoundingClientRect().x - viewportX; var isVisible = ( From 7798b17236d128ee07a9fe295d6dec0b0eb94083 Mon Sep 17 00:00:00 2001 From: KelseyCooper Date: Fri, 19 Feb 2021 16:01:13 -0800 Subject: [PATCH 2/2] Check for cellX being 0 for inline carousels --- js/flickity.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/flickity.js b/js/flickity.js index 2f42608..fedfd27 100644 --- a/js/flickity.js +++ b/js/flickity.js @@ -771,6 +771,7 @@ proto.checkVisibility = function() { this.cells.forEach(function (cell) { var cellX = cell.element.getBoundingClientRect().x - viewportX; var isVisible = ( + (cellX > -1 && cellX < 1) || (cellX + cell.size.innerWidth > viewportX) && (cellX + cell.size.innerWidth < viewportWidth) || (cellX > viewportX) && (cellX < viewportWidth) );