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

Commit

Permalink
fix(virtualRepeat): sets initial size for virtual repeat when the fir…
Browse files Browse the repository at this point in the history
…st results require shrinking

closes #5826
  • Loading branch information
Robert Messerle committed Dec 8, 2015
1 parent cdc9719 commit 41d25fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/virtualRepeat/virtual-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ VirtualRepeatContainerController.prototype.sizeScroller_ = function(size) {
VirtualRepeatContainerController.prototype.autoShrink_ = function(size) {
var shrinkSize = Math.max(size, this.autoShrinkMin * this.repeater.getItemSize());
if (this.autoShrink && shrinkSize !== this.size) {
if (shrinkSize < (this.originalSize || this.size)) {
var currentSize = this.originalSize || this.size;
if (!currentSize || shrinkSize < currentSize) {
if (!this.originalSize) {
this.originalSize = this.size;
}
Expand Down
15 changes: 15 additions & 0 deletions src/components/virtualRepeat/virtual-repeater.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,21 @@ describe('<md-virtual-repeat>', function() {
expect(offsetter.children().length).toBe(43);
});

it('should shrink when initial results require shrinking', inject(function() {
scope.items = [
{ value: 'alabama', display: 'Alabama' },
{ value: 'alaska', display: 'Alaska' },
{ value: 'arizona', display: 'Arizona' }
];
createRepeater();
var controller = component.controller('mdVirtualRepeatContainer');
controller.autoShrink = true;
controller.autoShrink_(200);

expect(component[0].getBoundingClientRect().height).toBe(200);
expect(offsetter.children().length).toBe(3);
}));

/**
* Facade to access transform properly even when jQuery is used;
* since jQuery's css function is obtaining the computed style (not wanted)
Expand Down

0 comments on commit 41d25fa

Please sign in to comment.