Skip to content

Instantly share code, notes, and snippets.

@jshirley
Created August 6, 2012 14:21
Show Gist options
  • Save jshirley/3274738 to your computer and use it in GitHub Desktop.
Save jshirley/3274738 to your computer and use it in GitHub Desktop.
FancyApp = Y.Base.create('fancyApp', Y.App, [ Y.App.ResponsiveViews, Y.App.Transitions ], {
views : {
GoalListView : {
type : NS.GoalListView,
responsive: [
{ view : 'GoalListPhoneView', condition: function() { /* Determine dynamically */ } },
{ view : 'GoalListPhoneView', 'maxWidth' : '480px' },
{ view : 'GoalListFullView', 'minWidth' : '481px' }
}
},
GoalListFullView : {
type : NS.GoalListView,
preserve : true
},
GoalListPhoneView : {
type : NS.GoalListView,
preserve : true
}
},
showGoalList : function() {
// Depending upon the dimensions, it may instead actually show
// GoalListPhoneView
this.showView('GoalListView');
}
});

Idea: Y.App.ResponsiveViews

Extending the view construction and creation based on responsive style breakpoints.

When the view is shown, Y.App will look at the dimensions of the browser and determine which view to show.

Browser resizing would trigger destruction of a preserved view, as well, and re-show the current active view (essentially a re-dispatch).

If the dimensions have not changed and the view is preserved, a previously established view will be activated.

If the dimensions have changed, the view will be reconstructed.

@juandopazo
Copy link

Another idea: Y.App.OnDemandViews:

  • createView should be potentially asynchronous and take a callback
  • A modules configuration option would specify which modules contain the view constructor
  • createView would check if the constructor exists, otherwise call Y.use(modules)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment