-
Notifications
You must be signed in to change notification settings - Fork 920
/
Gradient.js
39 lines (31 loc) · 954 Bytes
/
Gradient.js
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
'use strict';
var React = require('react');
var createComponent = require('./createComponent');
var LayerMixin = require('./LayerMixin');
var Gradient = createComponent('Gradient', LayerMixin, {
applyGradientProps: function (prevProps, props) {
var layer = this.node;
layer.type = 'gradient';
layer.colorStops = props.colorStops || [];
this.applyLayerProps(prevProps, props);
},
mountComponent: function (
transaction,
nativeParent,
nativeContainerInfo,
context
) {
var props = this._currentElement.props;
var layer = this.node;
this.applyGradientProps({}, props);
return layer;
},
receiveComponent: function (nextComponent, transaction, context) {
var prevProps = this._currentElement.props;
var props = nextComponent.props;
this.applyGradientProps({}, props);
this._currentElement = nextComponent;
this.node.invalidateLayout();
},
});
module.exports = Gradient;