blossom
Version:
Modern, Cross-Platform Application Framework
78 lines (55 loc) • 2.54 kB
JavaScript
// ==========================================================================
// Project: SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2010 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
/**
@namespace
__NOTE:__ 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 true.
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 positionining. 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.
h2. 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 true.
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.
h2. Example
{{{
// JavaScript
MyApp.CommentView = SC.View.extend(SC.StaticLayout, {
classNames: ['comment-view'],
useStaticLayout: true,
...
});
// CSS
.comment-view {
display: block;
position: relative;
}
}}}
@deprecated
@since SproutCore 1.0
*/
SC.StaticLayout = {
/**
Walk 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 true.
@property {Boolean}
*/
hasStaticLayout: true
};