Sha256: 3893d8efcf6752b8d536f7e795469bf2483ee49cb836a28283df44f8ec2e7a1f
Contents?: true
Size: 1.24 KB
Versions: 19
Compression:
Stored size: 1.24 KB
Contents
//= require ./adjacent_pages pageflow.AdjacentPreparer = pageflow.Object.extend({ initialize: function(adjacentPages) { this.adjacentPages = adjacentPages; }, attach: function(events) { this.listenTo(events, 'page:change', this.schedule); }, schedule: function(page) { clearTimeout(this.scheduleTimeout); var prepare = _.bind(this.prepareAdjacent, this, page.element.page('instance')); this.scheduleTimeout = setTimeout(prepare, page.prepareNextPageTimeout()); }, prepareAdjacent: function(page) { var adjacentPages = this.adjacentPages.of(page); var noLongerPreparedPages = _.difference(this.lastPreparedPages, adjacentPages, [page]); var newAdjacentPages = _.difference(adjacentPages, this.lastPreparedPages); _(noLongerPreparedPages).each(function(page) { if (!page.isDestroyed) { page.unprepare(); } }); _(newAdjacentPages).each(function(adjacentPage) { adjacentPage.prepare(); adjacentPage.preload(); }); this.lastPreparedPages = adjacentPages.concat([page]); } }); pageflow.AdjacentPreparer.create = function(pages, scrollNavigator) { return new pageflow.AdjacentPreparer( new pageflow.AdjacentPages( pages, scrollNavigator ) ); };
Version data entries
19 entries across 19 versions & 1 rubygems