Skip to content

Instantly share code, notes, and snippets.

@ohookins
Created September 7, 2014 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohookins/37e8dc49e12ffd71742d to your computer and use it in GitHub Desktop.
Save ohookins/37e8dc49e12ffd71742d to your computer and use it in GitHub Desktop.
Failed attempt at automatically adjusting content surface
// Constructor function for our ContentView class
function ContentView() {
// Applies View's constructor function to ContentView class
View.apply(this, arguments);
var content = TextData['mycontent'];
// Backgrounds
this.add(new Surface({
size: [undefined, undefined],
classes: ['black-bg']
}));
this.add(new StateModifier({
origin: [0.5, 0.5]
})).add(new Surface({
size: [1024, undefined],
classes: ['grey-bg']
}));
// Text
this.contentSurface = new Surface({
size: [500, this.getSize()[1]-100], // <--- THIS FAILS
classes: ['grey-bg', 'scrollable'],
content: content,
properties: {
textAlign: 'center'
}
});
// Center it in the content view
var centerModifier = new StateModifier({
origin: [0.5, 0.5],
transform: Transform.translate(0, 100, 0)
});
this.add(centerModifier).add(this.contentSurface);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment