From ef63d060ff40385fc90b03d40473f5c52522c209 Mon Sep 17 00:00:00 2001 From: Hannes Widmoser Date: Mon, 25 Apr 2016 10:15:20 +0200 Subject: [PATCH] Trigger scroll end when no scrollbar is visible --- dist/tileview.js | 7 +++++-- package.json | 2 +- src/tileview.ts | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dist/tileview.js b/dist/tileview.js index 3140af6..ff279c3 100644 --- a/dist/tileview.js +++ b/dist/tileview.js @@ -101,7 +101,10 @@ }); layout(); }); - scope.$watch('items', layout); + scope.$watch('items', function () { + lastScrollPosition = Number.NEGATIVE_INFINITY; + layout(); + }); scope.$on('td.tileview.resize', layout); angular.element($window).on('resize', onResize); scope.$on('$destroy', function () { @@ -127,7 +130,7 @@ function itemElementCount() { return itemContainer.children().length; } - var lastScrollPosition = 0; + var lastScrollPosition = Number.NEGATIVE_INFINITY; function updateVisibleRows() { function clamp(value, min, max) { return Math.max(Math.min(value, max), min); diff --git a/package.json b/package.json index 24383e5..cf7b0e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-tileview", - "version": "0.3.2", + "version": "0.3.3", "description": "A tileview for angular", "main": "gulpfile.js", "scripts": { diff --git a/src/tileview.ts b/src/tileview.ts index eb4850b..be8809b 100644 --- a/src/tileview.ts +++ b/src/tileview.ts @@ -110,7 +110,10 @@ declare const angular: any; }); layout(); }); - scope.$watch('items', layout); + scope.$watch('items', () => { + lastScrollPosition = Number.NEGATIVE_INFINITY; + layout(); + }); scope.$on('td.tileview.resize', layout); angular.element($window).on('resize', onResize); @@ -143,7 +146,7 @@ declare const angular: any; return itemContainer.children().length; } - let lastScrollPosition = 0; + let lastScrollPosition = Number.NEGATIVE_INFINITY; function updateVisibleRows() { function clamp(value, min, max) { return Math.max(Math.min(value, max), min);