@@ -56,55 +56,78 @@ return /******/ (function(modules) { // webpackBootstrap
56
56
57
57
'use strict' ;
58
58
59
- Object . defineProperty ( exports , '__esModule' , {
60
- value : true
61
- } ) ;
62
-
63
59
var _extends = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
64
60
65
- var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( ' value' in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
61
+ var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( " value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
66
62
67
- var _get = function get ( _x , _x2 , _x3 ) { var _again = true ; _function: while ( _again ) { var object = _x , property = _x2 , receiver = _x3 ; desc = parent = getter = undefined ; _again = false ; if ( object === null ) object = Function . prototype ; var desc = Object . getOwnPropertyDescriptor ( object , property ) ; if ( desc === undefined ) { var parent = Object . getPrototypeOf ( object ) ; if ( parent === null ) { return undefined ; } else { _x = parent ; _x2 = property ; _x3 = receiver ; _again = true ; continue _function ; } } else if ( 'value' in desc ) { return desc . value ; } else { var getter = desc . get ; if ( getter === undefined ) { return undefined ; } return getter . call ( receiver ) ; } } } ;
63
+ var _react = __webpack_require__ ( 1 ) ;
68
64
69
- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; }
65
+ var _react2 = _interopRequireDefault ( _react ) ;
70
66
71
- function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
67
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
72
68
73
- function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
69
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
74
70
75
- var _react = __webpack_require__ ( 1 ) ;
71
+ function _possibleConstructorReturn ( self , call ) { if ( ! self ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ; }
76
72
77
- var _react2 = _interopRequireDefault ( _react ) ;
73
+ function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
78
74
79
75
var bgImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEX5+fn///8pDrwNAAAAFElEQVQI12NgsP/AQAz+f4CBGAwAJIIdTTn0+w0AAAAASUVORK5CYII=' ;
80
76
81
- var ImageDiff = ( function ( _Component ) {
77
+ var ImageDiff = function ( _Component ) {
82
78
_inherits ( ImageDiff , _Component ) ;
83
79
84
- _createClass ( ImageDiff , null , [ {
85
- key : 'propTypes' ,
86
- value : {
87
- after : _react2 [ 'default' ] . PropTypes . string . isRequired ,
88
- before : _react2 [ 'default' ] . PropTypes . string . isRequired ,
89
- height : _react2 [ 'default' ] . PropTypes . number ,
90
- type : _react2 [ 'default' ] . PropTypes . string . isRequired ,
91
- value : _react2 [ 'default' ] . PropTypes . number ,
92
- width : _react2 [ 'default' ] . PropTypes . number
93
- } ,
94
- enumerable : true
95
- } , {
96
- key : 'defaultProps' ,
97
- value : {
98
- value : 1
99
- } ,
100
- enumerable : true
101
- } ] ) ;
102
-
103
80
function ImageDiff ( ) {
104
81
_classCallCheck ( this , ImageDiff ) ;
105
82
106
- _get ( Object . getPrototypeOf ( ImageDiff . prototype ) , 'constructor' , this ) . call ( this ) ;
107
- this . handleImgLoad = this . handleImgLoad . bind ( this ) ;
83
+ var _this = _possibleConstructorReturn ( this , Object . getPrototypeOf ( ImageDiff ) . call ( this ) ) ;
84
+
85
+ _this . renderFade = function ( ) {
86
+ var style = {
87
+ backgroundImage : 'url(' + bgImage + ')' ,
88
+ height : _this . state . height ,
89
+ margin : 0 ,
90
+ position : 'absolute' ,
91
+ width : _this . state . width
92
+ } ;
93
+
94
+ var beforeStyle = _extends ( {
95
+ border : '1px solid #f77'
96
+ } , style ) ;
97
+
98
+ var afterStyle = _extends ( {
99
+ border : '1px solid #63c363' ,
100
+ opacity : 1 - _this . props . value
101
+ } , style ) ;
102
+
103
+ return _react2 . default . createElement (
104
+ 'div' ,
105
+ { className : 'ImageDiff__inner--fade' , style : style } ,
106
+ _react2 . default . createElement (
107
+ 'div' ,
108
+ { className : 'ImageDiff__before' , style : beforeStyle } ,
109
+ _react2 . default . createElement ( 'img' , {
110
+ src : _this . props . before ,
111
+ height : _this . props . height ,
112
+ width : _this . props . width ,
113
+ onLoad : _this . handleImgLoad
114
+ } )
115
+ ) ,
116
+ _react2 . default . createElement (
117
+ 'div' ,
118
+ { className : 'ImageDiff__after' , style : afterStyle } ,
119
+ _react2 . default . createElement ( 'img' , {
120
+ src : _this . props . after ,
121
+ height : _this . props . height ,
122
+ width : _this . props . width ,
123
+ onLoad : _this . handleImgLoad
124
+ } )
125
+ )
126
+ ) ;
127
+ } ;
128
+
129
+ _this . handleImgLoad = _this . handleImgLoad . bind ( _this ) ;
130
+ return _this ;
108
131
}
109
132
110
133
_createClass ( ImageDiff , [ {
@@ -125,26 +148,21 @@ return /******/ (function(modules) { // webpackBootstrap
125
148
}
126
149
} , {
127
150
key : 'handleImgLoad' ,
128
- value : function handleImgLoad ( ref ) {
129
- var _this = this ;
130
-
131
- return function ( ) {
132
- if ( ! _this . props . height && ! _this . props . width ) {
133
- var _React$findDOMNode = _react2 [ 'default' ] . findDOMNode ( _this . refs [ ref ] ) ;
134
-
135
- var height = _React$findDOMNode . height ;
136
- var width = _React$findDOMNode . width ;
137
-
138
- _this . setState ( {
139
- height : height , width : width
140
- } ) ;
141
- }
142
- } ;
151
+ value : function handleImgLoad ( e ) {
152
+ if ( ! this . props . height && ! this . props . width ) {
153
+ var _e$target = e . target ;
154
+ var height = _e$target . height ;
155
+ var width = _e$target . width ;
156
+
157
+ this . setState ( {
158
+ height : height , width : width
159
+ } ) ;
160
+ }
143
161
}
144
162
} , {
145
163
key : 'render' ,
146
164
value : function render ( ) {
147
- return _react2 [ ' default' ] . createElement (
165
+ return _react2 . default . createElement (
148
166
'div' ,
149
167
{ className : 'ImageDiff' , style : { display : 'inline-block' , height : this . state . height , width : this . state . width } } ,
150
168
this . props . type === 'difference' ? this . renderDifference ( ) : null ,
@@ -165,77 +183,28 @@ return /******/ (function(modules) { // webpackBootstrap
165
183
} ;
166
184
var afterStyle = _extends ( { } , beforeStyle ) ;
167
185
168
- return _react2 [ ' default' ] . createElement (
186
+ return _react2 . default . createElement (
169
187
'div' ,
170
188
{ className : 'ImageDiff_inner--difference' , style : style } ,
171
- _react2 [ ' default' ] . createElement (
189
+ _react2 . default . createElement (
172
190
'div' ,
173
191
{ className : 'ImageDiff__before' , style : beforeStyle } ,
174
- _react2 [ 'default' ] . createElement ( 'img' , {
175
- ref : 'before' ,
192
+ _react2 . default . createElement ( 'img' , {
176
193
src : this . props . before ,
177
194
height : this . props . height ,
178
195
width : this . props . width ,
179
- onLoad : this . handleImgLoad ( 'before' )
196
+ onLoad : this . handleImgLoad
180
197
} )
181
198
) ,
182
- _react2 [ ' default' ] . createElement (
199
+ _react2 . default . createElement (
183
200
'div' ,
184
201
{ className : 'ImageDiff__after' , style : afterStyle } ,
185
- _react2 [ 'default' ] . createElement ( 'img' , {
186
- ref : 'after' ,
202
+ _react2 . default . createElement ( 'img' , {
187
203
src : this . props . after ,
188
204
height : this . props . height ,
189
205
width : this . props . width ,
190
206
style : { mixBlendMode : 'difference' } ,
191
- onLoad : this . handleImgLoad ( 'after' )
192
- } )
193
- )
194
- ) ;
195
- }
196
- } , {
197
- key : 'renderFade' ,
198
- value : function renderFade ( ) {
199
- var style = {
200
- backgroundImage : 'url(' + bgImage + ')' ,
201
- height : this . state . height ,
202
- margin : 0 ,
203
- position : 'absolute' ,
204
- width : this . state . width
205
- } ;
206
-
207
- var beforeStyle = _extends ( {
208
- border : '1px solid #f77'
209
- } , style ) ;
210
-
211
- var afterStyle = _extends ( {
212
- border : '1px solid #63c363' ,
213
- opacity : this . props . value
214
- } , style ) ;
215
-
216
- return _react2 [ 'default' ] . createElement (
217
- 'div' ,
218
- { className : 'ImageDiff__inner--fade' , style : style } ,
219
- _react2 [ 'default' ] . createElement (
220
- 'div' ,
221
- { className : 'ImageDiff__before' , style : beforeStyle } ,
222
- _react2 [ 'default' ] . createElement ( 'img' , {
223
- ref : 'before' ,
224
- src : this . props . before ,
225
- height : this . props . height ,
226
- width : this . props . width ,
227
- onLoad : this . handleImgLoad ( 'before' )
228
- } )
229
- ) ,
230
- _react2 [ 'default' ] . createElement (
231
- 'div' ,
232
- { className : 'ImageDiff__after' , style : afterStyle } ,
233
- _react2 [ 'default' ] . createElement ( 'img' , {
234
- ref : 'after' ,
235
- src : this . props . after ,
236
- height : this . props . height ,
237
- width : this . props . width ,
238
- onLoad : this . handleImgLoad ( 'after' )
207
+ onLoad : this . handleImgLoad
239
208
} )
240
209
)
241
210
) ;
@@ -270,32 +239,30 @@ return /******/ (function(modules) { // webpackBootstrap
270
239
width : this . state . width * ( 1 - this . props . value )
271
240
} ;
272
241
273
- return _react2 [ ' default' ] . createElement (
242
+ return _react2 . default . createElement (
274
243
'div' ,
275
244
{ className : 'ImageDiff__inner--swipe' , style : style } ,
276
- _react2 [ ' default' ] . createElement (
245
+ _react2 . default . createElement (
277
246
'div' ,
278
247
{ className : 'ImageDiff__before' , style : beforeStyle } ,
279
- _react2 [ 'default' ] . createElement ( 'img' , {
280
- ref : 'before' ,
248
+ _react2 . default . createElement ( 'img' , {
281
249
src : this . props . before ,
282
250
height : this . props . height ,
283
251
width : this . props . width ,
284
- onLoad : this . handleImgLoad ( 'before' )
252
+ onLoad : this . handleImgLoad
285
253
} )
286
254
) ,
287
- _react2 [ ' default' ] . createElement (
255
+ _react2 . default . createElement (
288
256
'div' ,
289
257
{ className : 'ImageDiff--swiper' , style : swiperStyle } ,
290
- _react2 [ ' default' ] . createElement (
258
+ _react2 . default . createElement (
291
259
'div' ,
292
260
{ className : 'ImageDiff__after' , style : afterStyle } ,
293
- _react2 [ 'default' ] . createElement ( 'img' , {
294
- ref : 'after' ,
261
+ _react2 . default . createElement ( 'img' , {
295
262
src : this . props . after ,
296
263
height : this . props . height ,
297
264
width : this . props . width ,
298
- onLoad : this . handleImgLoad ( 'after' )
265
+ onLoad : this . handleImgLoad
299
266
} )
300
267
)
301
268
)
@@ -304,10 +271,22 @@ return /******/ (function(modules) { // webpackBootstrap
304
271
} ] ) ;
305
272
306
273
return ImageDiff ;
307
- } ) ( _react . Component ) ;
308
-
309
- exports [ 'default' ] = ImageDiff ;
310
- module . exports = exports [ 'default' ] ;
274
+ } ( _react . Component ) ;
275
+
276
+ ImageDiff . propTypes = {
277
+ after : _react . PropTypes . string . isRequired ,
278
+ before : _react . PropTypes . string . isRequired ,
279
+ height : _react . PropTypes . number ,
280
+ type : _react . PropTypes . string . isRequired ,
281
+ value : _react . PropTypes . number ,
282
+ width : _react . PropTypes . number
283
+ } ;
284
+
285
+ ImageDiff . defaultProps = {
286
+ value : 1
287
+ } ;
288
+
289
+ module . exports = ImageDiff ;
311
290
312
291
/***/ } ,
313
292
/* 1 */
0 commit comments