(DEPRECATED) Mixin: SC.StaticLayout
SC.StaticLayout
is now built in to SC.View.
You do not need to
apply this mixin to use static layout. Just set useStaticLayout
to YES
.
Normally, SproutCore views use absolute positioning to display themselves on the screen. While this is both the fastest and most efficient way to display content in the web browser, sometimes your user interface might need to take advantage of the more advanced "flow" layout offered by the browser when you use static and relative positioning.
This mixin can be added to a view class to enable the use of any kind of
static and relative browser positioning. In exchange for using static
layout, you will lose a few features that are normally available on a view
class such as the 'frame' and 'clippingFrame' properties as well as
notifications when your view or parentView
are resized.
Normally, if you are allowing the browser to manage the size and positioning of your view, these feature will not be useful to your code anyway.
Using StaticLayout
To enable static layout on your view, just include this mixin on the view.
SproutCore's builtin views that are capable of being used in static
layouts already incorporate this mixin. Then set the "useStaticLayout"
property on your view class to YES
.
You can then use CSS or the render() method on your view to setup the positioning on your view using any browser layout mechanism you want.
Example
// JavaScript
MyApp.CommentView = SC.View.extend(SC.StaticLayout, {
classNames: ['comment-view'],
useStaticLayout: YES,
...
});
// CSS
.comment-view {
display: block;
position: relative;
}
Defined in: static_layout.js
- Since:
- SproutCore 1.0
Field Summary
- SC.StaticLayout.hasStaticLayout
Class Methods
Field Detail
SC.StaticLayout.hasStaticLayout BooleanWalk like a duck. Used to determine that this mixin has been applied.
Note that a view that hasStaticLayout
still may not actually use static
layout unless useStaticLayout
is also set to YES
.
- Default value:
- YES