File tree Expand file tree Collapse file tree 4 files changed +65
-0
lines changed Expand file tree Collapse file tree 4 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ /** @jsx React.DOM */
2+
3+ 'use strict' ;
4+
5+ var React = require ( 'react' ) ;
6+ var ReactCanvas = require ( 'react-canvas' ) ;
7+
8+ var Gradient = ReactCanvas . Gradient ;
9+ var Surface = ReactCanvas . Surface ;
10+
11+ var App = React . createClass ( {
12+
13+ render : function ( ) {
14+ var size = this . getSize ( ) ;
15+ return (
16+ < Surface top = { 0 } left = { 0 } width = { size . width } height = { size . height } >
17+ < Gradient style = { this . getGradientStyle ( ) }
18+ colorStops = { this . getGradientColors ( ) } />
19+ </ Surface >
20+ ) ;
21+ } ,
22+
23+ getGradientStyle : function ( ) {
24+ var size = this . getSize ( ) ;
25+ return {
26+ top : 0 ,
27+ left : 0 ,
28+ width : size . width ,
29+ height : size . height
30+ } ;
31+ } ,
32+
33+ getGradientColors : function ( ) {
34+ return [
35+ { color : "transparent" , position : 0 } ,
36+ { color : "#000" , position : 1 }
37+ ] ;
38+ } ,
39+
40+ getSize : function ( ) {
41+ return document . getElementById ( 'main' ) . getBoundingClientRect ( ) ;
42+ }
43+
44+ } ) ;
45+
46+ React . render ( < App /> , document . getElementById ( 'main' ) ) ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta http-equiv ="Content-type " content ="text/html; charset=utf-8 ">
5+ < meta name ="viewport " content ="initial-scale=1.0, maximum-scale=1.0, user-scalable=no ">
6+ < title > ReactCanvas: ListView</ title >
7+ < link rel ="stylesheet " type ="text/css " href ="/examples/common/examples.css ">
8+ < script src ="/examples/common/touch-emulator.js "> </ script >
9+ < script type ="text/javascript ">
10+ TouchEmulator ( ) ;
11+ </ script >
12+ </ head >
13+ < body >
14+ < div id ="main "> </ div >
15+ < script src ="/build/gradient.js "> </ script >
16+ </ body >
17+ </ html >
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var ReactCanvas = {
88 Image : require ( './Image' ) ,
99 Text : require ( './Text' ) ,
1010 ListView : require ( './ListView' ) ,
11+ Gradient : require ( './Gradient' ) ,
1112
1213 FontFace : require ( './FontFace' ) ,
1314 measureText : require ( './measureText' )
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ module.exports = {
66 entry : {
77 'listview' : [ './examples/listview/app.js' ] ,
88 'timeline' : [ './examples/timeline/app.js' ] ,
9+ 'gradient' : [ './examples/gradient/app.js' ] ,
910 'css-layout' : [ './examples/css-layout/app.js' ]
1011 } ,
1112
You can’t perform that action at this time.
0 commit comments