YUI.add('pnm-grid-view', function (Y) {

var PNM       = Y.PNM,
    Templates = PNM.Templates,
    GridView;

GridView = Y.Base.create('gridView', Y.View, [], {

    containerTemplate: '<div class="grid" />',
    template         : Templates['grid'],
    photoTemplate    : Templates['grid-photo'],

    events: {
        '.photo': {click: 'select'}
    },

    initializer: function (config) {
        var photos = this.get('photos');

        photos.after('reset', this.render, this);

        this.loadingNode     = null;
        this._maxKnownHeight = 0;

        this.publish('more', {preventable: false});

        Y.one('win').on(['scroll', 'resize'], this.more, this);
    },

    render: function () {
        var photos    = this.get('photos'),
            container = this.get('container'),
            content;

        content = this.template({
            photos: photos.map(function (photo) {
                return photo.getAttrs(['id', 'title', 'thumbUrl']);
            })
        }, {
            partials: {'grid-photo': this.photoTemplate}
        });

        container.setContent(content);
        this.loadingNode = container.one('.loading');

        // Only try to load more photos if we already have some photos. This
        // prevents the lazily-loaded photos from duplicating.
        if (!photos.isEmpty()) {
            Y.later(1, this, 'more');
        }

        return this;
    },

    more: function (e) {
        var viewportBottom = Y.DOM.viewportRegion().bottom,
            maxKnowHeight  = this._maxKnownHeight,
            containerBottom;

        if (viewportBottom <= maxKnowHeight) { return; }

        containerBottom = this.get('container').get('region').bottom;

        if ((viewportBottom + 150) > containerBottom && containerBottom > maxKnowHeight) {
            this._maxKnownHeight = containerBottom;
            this.loadingNode.show();
            this.fire('more');
        }
    },

    select: function (e) {
        this.get('container').all('.photo.selected').removeClass('selected');
        e.currentTarget.addClass('selected');
    },

    reset: function () {
        this._maxKnownHeight = 0;
        this.get('container').all('.photo.selected').removeClass('selected');
        return this;
    }

});

Y.namespace('PNM').GridView = GridView;

}, '0.5.0', {
    requires: [
        'node-style',
        'node-screen',
        'pnm-photos',
        'pnm-templates',
        'view'
    ]
});

@@ -485,45 +485,8 @@
 );%0A%0A
-        this.loadingNode     = null;%0A
     
@@ -515,16 +515,16 @@
 ht = 0;%0A
+
 %0A       
@@ -632,16 +632,238 @@
 , this);
+%0A%0A        // Only try to load more photos if we already have some photos. This%0A        // prevents the lazily-loaded photos from duplicating.%0A        if (!photos.isEmpty()) %7B%0A            Y.later(1, this, 'more');%0A        %7D
 %0A    %7D,%0A
@@ -1295,285 +1295,8 @@
 t);%0A
-        this.loadingNode = container.one('.loading');%0A%0A        // Only try to load more photos if we already have some photos. This%0A        // prevents the lazily-loaded photos from duplicating.%0A        if (!photos.isEmpty()) %7B%0A            Y.later(1, this, 'more');%0A        %7D%0A%0A
     
@@ -1459,32 +1459,43 @@
 ght,%0A           
+ container,
  containerBottom
@@ -1572,22 +1572,22 @@
 ontainer
-Bottom
+      
  = this.
@@ -1602,16 +1602,53 @@
 tainer')
+;%0A        containerBottom = container
 .get('re
@@ -1822,20 +1822,31 @@
     
-this
+container.one('
 .loading
 Node
@@ -1845,12 +1845,10 @@
 ding
-Node
+')
 .sho

Improve how the GridView initializes when its the app's initial view.