From b8ebaba3f437d7735b58c22e6f33e3c2ca7a0be7 Mon Sep 17 00:00:00 2001 From: Hannes Widmoser Date: Thu, 19 May 2016 11:06:08 +0200 Subject: [PATCH] Fix scrolling on firefox --- dist/tileview.js | 13 ++++++++----- package.json | 2 +- src/tileview.ts | 13 ++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dist/tileview.js b/dist/tileview.js index 02aaa7d..ea7caec 100644 --- a/dist/tileview.js +++ b/dist/tileview.js @@ -144,7 +144,6 @@ var itemSize = scope.options.tileSize[sizeDimension]; var maxScrollPosition = rowCount * itemSize - rect[sizeDimension]; var scrollDimension = scope.options.alignHorizontal ? 'scrollLeft' : 'scrollTop'; - container[0][scrollDimension] = clamp(container[0][scrollDimension], 0, maxScrollPosition); var scrollPosition = container[0][scrollDimension]; var scrollEndThreshold = maxScrollPosition - scope.options.scrollEndOffset * itemSize; if (scrollPosition >= scrollEndThreshold && !(lastScrollPosition >= scrollEndThreshold) && scope.options.onScrollEnd !== undefined) { @@ -170,10 +169,14 @@ } } function setPlaceholder() { - heightStart = Math.max(startRow * scope.options.tileSize[sizeDimension], 0); - heightEnd = Math.max((rowCount - endRow) * scope.options.tileSize[sizeDimension], 0); - placeholderStart.css(sizeDimension, heightStart + 'px'); - placeholderEnd.css(sizeDimension, heightEnd + 'px'); + var newHeightStart = Math.max(startRow * scope.options.tileSize[sizeDimension], 0); + var newHeightEnd = Math.max((rowCount - endRow) * scope.options.tileSize[sizeDimension], 0); + if (newHeightStart !== heightStart || newHeightEnd !== heightEnd) { + placeholderStart.css(sizeDimension, newHeightStart + 'px'); + placeholderEnd.css(sizeDimension, newHeightEnd + 'px'); + heightStart = newHeightStart; + heightEnd = newHeightEnd; + } } function createElements(diff) { updateVisibleRows(); diff --git a/package.json b/package.json index 27c73bb..c218154 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-tileview", - "version": "0.5.2", + "version": "0.5.7", "description": "A tileview for angular", "main": "gulpfile.js", "scripts": { diff --git a/src/tileview.ts b/src/tileview.ts index 7be5313..296ee2b 100644 --- a/src/tileview.ts +++ b/src/tileview.ts @@ -163,7 +163,6 @@ declare const angular: any; const maxScrollPosition = rowCount*itemSize - rect[sizeDimension]; const scrollDimension = scope.options.alignHorizontal ? 'scrollLeft' : 'scrollTop'; - container[0][scrollDimension] = clamp(container[0][scrollDimension], 0, maxScrollPosition); const scrollPosition = container[0][scrollDimension]; const scrollEndThreshold = maxScrollPosition - scope.options.scrollEndOffset*itemSize; @@ -192,10 +191,14 @@ declare const angular: any; } function setPlaceholder() { - heightStart = Math.max(startRow * scope.options.tileSize[sizeDimension], 0); - heightEnd = Math.max((rowCount - endRow) * scope.options.tileSize[sizeDimension], 0); - placeholderStart.css(sizeDimension, heightStart + 'px'); - placeholderEnd.css(sizeDimension, heightEnd + 'px'); + const newHeightStart = Math.max(startRow * scope.options.tileSize[sizeDimension], 0); + const newHeightEnd = Math.max((rowCount - endRow) * scope.options.tileSize[sizeDimension], 0); + if (newHeightStart !== heightStart || newHeightEnd !== heightEnd) { + placeholderStart.css(sizeDimension, newHeightStart + 'px'); + placeholderEnd.css(sizeDimension, newHeightEnd + 'px'); + heightStart = newHeightStart; + heightEnd = newHeightEnd; + } } function createElements(diff) {