-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed implementation for an optimized performance
- Loading branch information
Showing
13 changed files
with
669 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
docs/src/app/components/examples/app-bar-waterfall-example.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.