From bfa059ef0b2805cfc5512f82becd50bbd0145544 Mon Sep 17 00:00:00 2001 From: Rhett Sutphin Date: Mon, 23 Mar 2015 17:01:00 -0500 Subject: [PATCH 1/2] Determine bottommost visible view for wrapped containers correctly. The previous expression (offset + wrapperTop) was only correct when the wrapped container was positioned at the top of the document. If the container was further down from the top of the document than the height of the last row, the last row would always be cloaked. The further down the container started, the more of the bottommost rows would always be cloaked. This was because "viewTop" was computed using document-relative coordinates, but was compared to a value (viewportBottom) that was clamped to the height of the container's content. This change uses a coordinate for viewTop which is relative to the scrolling container. --- addon/views/cloaked-collection.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addon/views/cloaked-collection.js b/addon/views/cloaked-collection.js index cc75a1f..69e3d49 100644 --- a/addon/views/cloaked-collection.js +++ b/addon/views/cloaked-collection.js @@ -159,9 +159,7 @@ export default Ember.CollectionView.extend({ while (bottomView < childViews.length) { var view = childViews[bottomView], $view = view.$(), - // in case of not full-window scrolling - scrollOffset = this.get('wrapperTop') || 0, - viewTop = $view.offset().top + scrollOffset, + viewTop = $view.position().top, viewBottom = viewTop + $view.height(); if (viewTop > viewportBottom) { break; } From 113f502c70e9542c33516348d09ad53c52fc9dfa Mon Sep 17 00:00:00 2001 From: Rhett Sutphin Date: Mon, 23 Mar 2015 17:06:48 -0500 Subject: [PATCH 2/2] .position() is already relative to the scroll container. Incorporating wrapperTop into the calculated viewBottom shifts the computed bounds for all the views such that the first row is always found to be the topmost visible. Top put it another way, it prevents any of the views that scroll above the top from ever being cloaked when you're using a wrapper element. --- addon/views/cloaked-collection.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addon/views/cloaked-collection.js b/addon/views/cloaked-collection.js index 69e3d49..ee55161 100644 --- a/addon/views/cloaked-collection.js +++ b/addon/views/cloaked-collection.js @@ -96,13 +96,11 @@ export default Ember.CollectionView.extend({ findTopView: function(childViews, viewportTop, min, max) { if (max < min) { return min; } - var wrapperTop = this.get('wrapperTop')>>0; - while(max>min){ var mid = Math.floor((min + max) / 2), // in case of not full-window scrolling $view = childViews[mid].$(), - viewBottom = $view.position().top + wrapperTop + $view.height(); + viewBottom = $view.position().top + $view.height(); if (viewBottom > viewportTop) { max = mid-1;