Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

virtual-repeat incorrectly sizes itself inside ng-show #4911

Closed
elubin opened this issue Sep 29, 2015 · 4 comments
Closed

virtual-repeat incorrectly sizes itself inside ng-show #4911

elubin opened this issue Sep 29, 2015 · 4 comments
Assignees
Milestone

Comments

@elubin
Copy link

elubin commented Sep 29, 2015

I wrap the md-virtual-repeat-container in a div with ng-show so I can hide the whole block when my list has no elements. I then fetch my elements with AJAX and fill my list which shows the block. The control incorrectly gets a height of 0 (and default to NUM_EXTRA height).

updateIndexes_ method
this.container.getSize() evaluates to 0

VirtualRepeatController.prototype.updateIndexes_ = function() {
var itemsLength = this.items ? this.items.length : 0;
var containerLength = Math.ceil(this.container.getSize() / this.itemSize);
this.newStartIndex = Math.max(0, Math.min(
itemsLength - containerLength,
Math.floor(this.container.getScrollOffset() / this.itemSize)));
this.newVisibleEnd = this.newStartIndex + containerLength + NUM_EXTRA;
this.newEndIndex = Math.min(itemsLength, this.newVisibleEnd);
this.newStartIndex = Math.max(0, this.newStartIndex - NUM_EXTRA);
};

Here is a fiddle to demonstrate the error against master branch
http://jsfiddle.net/elubin/d0wsmLqn/

@elubin
Copy link
Author

elubin commented Sep 29, 2015

By the way, for anyone that does hit this issue, the workaround is to use ng-if instead of ng-show

@ThomasBurleson ThomasBurleson modified the milestone: 0.12.0 Oct 5, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc1, 1.0-rc2, 1.0-rc3 Oct 27, 2015
@danielsig
Copy link

Here's the same problem except I'm trying to animate the height using CSS animations.
using ng-show: http://plnkr.co/edit/3HI7NN4CqdXkOcTERzxX?p=preview
using ng-if: http://plnkr.co/edit/s1MDkHCLu05HjwlMmmkA?p=preview

@kseamon
Copy link
Contributor

kseamon commented Nov 2, 2015

This is essentially the same bug as #4314. Hoping to fix it this week but we'll see.

@kseamon
Copy link
Contributor

kseamon commented Nov 2, 2015

...and is a dupe of #4336.

@kseamon kseamon closed this as completed Nov 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants