-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathindex.html
More file actions
140 lines (132 loc) · 3.88 KB
/
Copy pathindex.html
File metadata and controls
140 lines (132 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>React Diff Image</title>
<style>
body {
font-family: "Helvetica Neue", Helvetica, sans-serif;
font-weight: 200;
margin: 0 auto;
width: 750px;
}
textarea {
font-family: monospace;
font-size: inherit;
height: 150px;
width: 100%;
}
pre {
white-space: pre-wrap;
}
label {
display: block;
}
</style>
</head>
<body>
<div id="root"></div>
<script src="//fb.me/react-with-addons-0.14.7.js"></script>
<script src="//fb.me/react-dom-0.14.7.js"></script>
<script src="//npmcdn.com/babel-transform-in-browser@6.4.6/dist/btib.min.js"></script>
<script src="dist/react-image-diff.js"></script>
<script type="text/es2015">
var imageSets = {
aralSea: {
before: './public/img/aralSea-1970.jpg',
after: './public/img/aralSea-2014.jpg',
height: 281,
width: 500
},
background: {
before: './public/img/background-0.png',
after: './public/img/background-1.png'
},
monocle: {
before: './public/img/monocle-0.jpg',
after: './public/img/monocle-1.jpg'
},
'spotTheDifference': {
before: './public/img/spot-the-difference-a.jpg',
after: './public/img/spot-the-difference-b.jpg'
},
'spotTheDifference2': {
before: './public/img/spot-the-difference-2a.jpg',
after: './public/img/spot-the-difference-2b.jpg'
},
yellowstone: {
before: './public/img/yellowstone-1988.jpg',
after: './public/img/yellowstone-1990.jpg',
height: 500,
width: 500
}
};
var App = React.createClass({
getInitialState: function() {
return {
images: 'monocle',
type: 'fade',
value: .5
};
},
handleImageSelect: function(e) {
this.setState({images: e.target.value});
},
handleInputChange: function(e) {
this.setState({
value: parseFloat(e.target.value)
});
},
handleRadioChange: function(e) {
this.setState({type: e.target.value});
},
render: function () {
var images = imageSets[this.state.images];
return (
<div>
<h1>react-image-diff</h1>
<select onChange={this.handleImageSelect}>
<option value='monocle'>Monocle</option>
<option value='background'>Background</option>
<option value='aralSea'>Aral Sea 1970-2014</option>
<option value='spotTheDifference'>Spot the Difference 1</option>
<option value='spotTheDifference2'>Spot the Difference 2</option>
<option value='yellowstone'>Yellowstone Fire 1988</option>
</select>
<div>
<ImageDiff
{...images}
type={this.state.type}
value={this.state.value}
/>
</div>
<input
type='range'
defaultValue={this.state.value}
min={0}
max={1}
step={.01}
onChange={this.handleInputChange}
disabled={this.state.type === 'difference' ? true : false}
/>
<br/>
<label>
<input name='type' type='radio' value='swipe' onChange={this.handleRadioChange} />
swipe
</label>
<label>
<input name='type' type='radio' value='fade' onChange={this.handleRadioChange} defaultChecked />
fade
</label>
<label>
<input name='type' type='radio' value='difference' onChange={this.handleRadioChange} />
difference
</label>
</div>
);
}
});
ReactDOM.render(<App/>, document.getElementById('root'));
</script>
</body>
</html>