Created
October 6, 2015 00:58
-
-
Save lukemelia/5719e2cae9c5c1ea6ab7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import ShelfFirst from 'layout-bin-packer/shelf-first'; | |
export default class ListWithHeaders | |
{ | |
constructor(content, width) { | |
this.content = content; | |
this.width = width; | |
this.bin = new ShelfFirst(content, width); | |
var bin = this.bin; | |
bin.length = function() { | |
return content.get('length'); | |
}; | |
bin.widthAtIndex = function() { | |
return width; | |
}; | |
bin.heightAtIndex = function(index) { | |
if (this.content.objectAt(index).group) { | |
return 37; | |
} | |
return 49; | |
}; | |
} | |
contentSize(clientSize) { | |
return { | |
width: clientSize.width, | |
height: this.bin.height() | |
}; | |
} | |
indexAt(offsetX, offsetY, width, height) { | |
return this.bin.visibleStartingIndex(offsetY, width, height); | |
} | |
positionAt(index, width /*,height*/) { | |
var position = this.bin.position(index, width); | |
return position; | |
} | |
widthAt() { | |
return this.width; | |
} | |
heightAt(index) { | |
return this.bin.heightAtIndex(index); | |
} | |
count(offsetX, offsetY, width, height) { | |
return this.bin.numberVisibleWithin(offsetY, width, height, true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment