From 6ccd0b5d2ee52fddccf1104f2d1a49b3260ae8ff Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Sun, 29 Nov 2015 01:14:46 -0500 Subject: [PATCH] fix: handle scrolling offset by resetting zone's box --- src/collection.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/collection.js b/src/collection.js index b3553b0..653ed42 100644 --- a/src/collection.js +++ b/src/collection.js @@ -44,8 +44,7 @@ function Collection (manager, options) { self.options.maxNumberOfNipples = 1; } - self.box = self.options.zone.getBoundingClientRect(); - + self.updateBox(); self.prepareNipples(); self.bindings(); self.begin(); @@ -173,6 +172,11 @@ Collection.prototype.createNipple = function (position, identifier) { return nipple; }; +Collection.prototype.updateBox = function () { + var self = this; + self.box = self.options.zone.getBoundingClientRect(); +}; + Collection.prototype.bindNipple = function (nipple) { var self = this; var type; @@ -214,6 +218,9 @@ Collection.prototype.onstart = function (evt) { var opts = self.options; evt = u.prepareEvent(evt); + // Update the box position + self.updateBox(); + var process = function (touch) { // If we can create new nipples // meaning we don't have more active nipples than we should.