Skip to content

Commit

Permalink
implemented waterfall
Browse files Browse the repository at this point in the history
changed implementation for an optimized performance
  • Loading branch information
igorbt committed Dec 10, 2015
1 parent 0e358b9 commit 42068dc
Show file tree
Hide file tree
Showing 13 changed files with 669 additions and 319 deletions.
101 changes: 54 additions & 47 deletions docs/src/app/app-routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import Tabs from './components/pages/components/tabs';
import TextFields from './components/pages/components/text-fields';
import TimePicker from './components/pages/components/time-picker';
import Toolbars from './components/pages/components/toolbars';
import AppBarWaterfall from './components/examples/app-bar-waterfall';


/**
Expand All @@ -61,57 +62,63 @@ import Toolbars from './components/pages/components/toolbars';
* handler and its parent handler like so: Paper > Components > Master
*/
const AppRoutes = (
<Route path="/" component={Master}>
<Route path="home" component={Home} />
<Redirect from="get-started" to="/get-started/prerequisites" />
<Route path="get-started" component={GetStarted}>
<Route path="prerequisites" component={Prerequisites} />
<Route path="installation" component={Installation} />
<Route path="examples" component={Examples} />
</Route>
<Route>
<Route path="/" component={Master}>
<Route path="home" component={Home} />
<Redirect from="get-started" to="/get-started/prerequisites" />
<Route path="get-started" component={GetStarted}>
<Route path="prerequisites" component={Prerequisites} />
<Route path="installation" component={Installation} />
<Route path="examples" component={Examples} />
</Route>

<Redirect from="customization" to="/customization/themes" />
<Route path="customization" component={Customization}>
<Route path="colors" component={Colors} />
<Route path="themes" component={Themes} />
<Route path="inline-styles" component={InlineStyles} />
</Route>
<Redirect from="customization" to="/customization/themes" />
<Route path="customization" component={Customization}>
<Route path="colors" component={Colors} />
<Route path="themes" component={Themes} />
<Route path="inline-styles" component={InlineStyles} />
</Route>

<Redirect from="components" to="/components/app-bar" />
<Route path="components" component={Components}>
<Route path="app-bar" component={AppBar} />
<Route path="auto-complete" component={AutoComplete} />
<Route path="avatar" component={Avatar} />
<Route path="badge" component={Badge} />
<Route path="buttons" component={Buttons} />
<Route path="cards" component={Cards} />
<Route path="date-picker" component={DatePicker} />
<Route path="dialog" component={Dialog} />
<Route path="dropdown-menu" component={DropDownMenu} />
<Route path="grid-list" component={GridList} />
<Route path="icons" component={Icons} />
<Route path="icon-buttons" component={IconButtons} />
<Route path="icon-menus" component={IconMenus} />
<Route path="left-nav" component={LeftNav} />
<Route path="lists" component={Lists} />
<Route path="menus" component={Menus} />
<Route path="paper" component={Paper} />
<Route path="popover" component={Popover} />
<Route path="progress" component={Progress} />
<Route path="refresh-indicator" component={RefreshIndicator} />
<Route path="select-fields" component={SelectFields} />
<Route path="sliders" component={Sliders} />
<Route path="switches" component={Switches} />
<Route path="snackbar" component={Snackbar} />
<Route path="table" component={Table} />
<Route path="tabs" component={Tabs} />
<Route path="text-fields" component={TextFields} />
<Route path="time-picker" component={TimePicker} />
<Route path="toolbars" component={Toolbars} />
</Route>
<Redirect from="components" to="/components/appbar" />
<Route path="components" component={Components}>
<Route path="appbar" component={AppBar} />
<Route path="auto-complete" component={AutoComplete} />
<Route path="avatar" component={Avatar} />
<Route path="badge" component={Badge} />
<Route path="buttons" component={Buttons} />
<Route path="cards" component={Cards} />
<Route path="date-picker" component={DatePicker} />
<Route path="dialog" component={Dialog} />
<Route path="dropdown-menu" component={DropDownMenu} />
<Route path="grid-list" component={GridList} />
<Route path="icons" component={Icons} />
<Route path="icon-buttons" component={IconButtons} />
<Route path="icon-menus" component={IconMenus} />
<Route path="left-nav" component={LeftNav} />
<Route path="lists" component={Lists} />
<Route path="menus" component={Menus} />
<Route path="paper" component={Paper} />
<Route path="popover" component={Popover} />
<Route path="progress" component={Progress} />
<Route path="refresh-indicator" component={RefreshIndicator} />
<Route path="select-fields" component={SelectFields} />
<Route path="sliders" component={Sliders} />
<Route path="switches" component={Switches} />
<Route path="snackbar" component={Snackbar} />
<Route path="table" component={Table} />
<Route path="tabs" component={Tabs} />
<Route path="text-fields" component={TextFields} />
<Route path="time-picker" component={TimePicker} />
<Route path="toolbars" component={Toolbars} />
</Route>

<IndexRoute component={Home}/>
<IndexRoute component={Home}/>
</Route>
<Route path="/examples">
<Route path="app-bar-waterfall" component={AppBarWaterfall} />
</Route>
</Route>

);

export default AppRoutes;
1 change: 1 addition & 0 deletions docs/src/app/components/AppBar/ExampleIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const AppBarExampleIcon = React.createClass({
return (
<AppBar
title="Title"
position="static"
iconClassNameRight="muidocs-icon-navigation-expand-more"
/>
);
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/components/AppBar/ExampleIconButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AppBarExampleIconButton = React.createClass({
return (
<AppBar
title={<span style={styles.title} onTouchTap={handleTouchTap}>Title</span>}
position="static"
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={<FlatButton label="Save" />}
/>
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/components/AppBar/ExampleIconMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const AppBarExampleIconMenu = React.createClass({
return (
<AppBar
title="Title"
position="static"
iconElementLeft={<IconButton><NavigationClose /></IconButton>}
iconElementRight={
<IconMenu
Expand Down
79 changes: 79 additions & 0 deletions docs/src/app/components/examples/app-bar-waterfall-example.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';
import {AppBar} from 'material-ui';

import IconButton from 'icon-button';
import MoreVertIcon from 'svg-icons/navigation/more-vert';
import ArrowBack from 'svg-icons/navigation/arrow-back';

const AppBarWaterfallExample = React.createClass({

render() {
return (
<AppBar
position="waterfall"
waterfall={{
minHeight: 64,
maxHeight: 210,
children: this.getWaterfallChildren(),
onHeightChange: this.onHeightChange,
}}
title={
<div
ref={el => { this.titleEl = el; }}>
Waterfall AppBar
</div>
}
iconElementLeft={
<IconButton onClick={this.onBackClick}>
<ArrowBack />
</IconButton>
}
iconElementRight={
<IconButton>
<MoreVertIcon/>
</IconButton>
}
/>
);
},

getWaterfallChildren() {
let styles = this.getStyles();
return (
<div
style={{overflow: 'hidden'}}>
<img
ref={el => { this.logoEl = el; }}
style={styles.logo}
src="images/material-ui-logo.svg"/>
</div>
);
},

onHeightChange({height, minHeight, maxHeight}) {
let interpolation = (height - minHeight) / (maxHeight - minHeight);

// For best performance, we will directly modify style on DOM elements
this.logoEl.style.transform = `translate3d(80px,0,0) scale3d(${interpolation}, ${interpolation}, 1)`;
this.logoEl.style.opacity = interpolation;
this.titleEl.style.opacity = 1 - interpolation;
},

onBackClick() {
window.history.back();
},

getStyles() {
return {
logo: {
height: 120,
margin: '0 auto',
display: 'block',
transformOrigin: '25% 100% 0',
transform: 'translate3d(80px,0,0)',
},
};
},
});

export default AppBarWaterfallExample;
74 changes: 74 additions & 0 deletions docs/src/app/components/examples/app-bar-waterfall.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import {AppCanvas, Styles, Mixins} from 'material-ui';

import CodeExample from '../code-example/code-example';
import FullWidthSection from '../full-width-section';

import AppBarWaterfallExample from './app-bar-waterfall-example';
import AppBarWaterfallExampleCode from '!raw!./app-bar-waterfall-example';

const {StylePropable} = Mixins;
const {Typography} = Styles;
const ThemeManager = Styles.ThemeManager;
const DefaultRawTheme = Styles.LightRawTheme;

const AppBarWaterfall = React.createClass({

mixins: [StylePropable],

getInitialState() {
let muiTheme = ThemeManager.getMuiTheme(DefaultRawTheme);
// To switch to RTL...
// muiTheme.isRtl = true;
return {
muiTheme,
};
},

contextTypes: {
router: React.PropTypes.func,
},

childContextTypes: {
muiTheme: React.PropTypes.object,
},

getChildContext() {
return {
muiTheme: this.state.muiTheme,
};
},

getStyles() {
return {
headline: {
//headline
fontSize: '24px',
lineHeight: '32px',
paddingTop: '16px',
marginBottom: '12px',
letterSpacing: '0',
fontWeight: Typography.fontWeightNormal,
color: Typography.textDarkBlack,
},
};
},

render() {
let styles = this.getStyles();
return (
<AppCanvas>
<AppBarWaterfallExample/>
<FullWidthSection>
<h2 style={styles.headline}>Waterfall AppBar</h2>

<p>Here is an example of how you can obtain a nice animation effect on scroll
when using position waterfall.</p>
<CodeExample code={AppBarWaterfallExampleCode}/>
</FullWidthSection>
</AppCanvas>
);
},
});

export default AppBarWaterfall;
Loading

0 comments on commit 42068dc

Please sign in to comment.