Created
August 6, 2010 03:40
-
-
Save alexissmirnov/510796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nav.testArray = []; | |
Nav.TestItem = SC.StaticContentView.extend({}); | |
Nav.mainPage = SC.Page.design({ | |
add: function() { | |
Nav.testArray.insertAt(Nav.testArray.length, 'some content some content some content some content some content some content'); | |
} | |
childViews: [ | |
SC.ScrollView.design({ | |
layout: {top: 60, left: 10, width: 200, height: 300}, | |
hasHorizontalScroller: NO, | |
contentView: SC.ListView.design({ | |
exampleView: Nav.TestItem, | |
contentBinding: 'Nav.testArray', | |
customRowHeightIndexes: null, | |
contentIndexRowHeight: function(view, content, idx) { | |
return 60; | |
}, | |
testArrayDidChange: function () { | |
if( !this.get('customRowHeightIndexes') ) | |
this.set('customRowHeightIndexes', SC.IndexSet.create()); | |
this.customRowHeightIndexes.add(0, Nav.testArray.length); | |
}.observes('Nav.testArray.[]') | |
}) | |
}), | |
SC.ButtonView.design({ | |
layout: {top: 10, left: 10, width: 200, height: 44}, | |
title: 'add', | |
action: 'add', | |
target: 'Nav.mainPage' | |
})] | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist illustrates the simplest possible use of custom row height in a ListBox. In this case all rows are set to the same size of 60.
The ScrollView shows the list items, but the scrolling is badly mandled. Scrolling up and down shows incorrect offsets between items - showing big empty areas, overlapping items.