UNPKG

2.77 kBJavaScriptView Raw
1import ReanimatedModule from './ReanimatedModule';
2
3/**
4 * Styles allowed to be direcly updated in UI thread
5 */
6let UI_THREAD_PROPS_WHITELIST = {
7 opacity: true,
8 transform: true,
9 /* colors */
10 backgroundColor: true,
11 borderRightColor: true,
12 borderBottomColor: true,
13 borderColor: true,
14 borderEndColor: true,
15 borderLeftColor: true,
16 borderStartColor: true,
17 borderTopColor: true,
18 /* ios styles */
19 shadowOpacity: true,
20 shadowRadius: true,
21 /* legacy android transform properties */
22 scaleX: true,
23 scaleY: true,
24 translateX: true,
25 translateY: true,
26};
27
28/**
29 * Whitelist of view props that can be updated in native thread via UIManagerModule
30 */
31let NATIVE_THREAD_PROPS_WHITELIST = {
32 borderBottomWidth: true,
33 borderEndWidth: true,
34 borderLeftWidth: true,
35 borderRightWidth: true,
36 borderStartWidth: true,
37 borderTopWidth: true,
38 borderWidth: true,
39 bottom: true,
40 flex: true,
41 flexGrow: true,
42 flexShrink: true,
43 height: true,
44 left: true,
45 margin: true,
46 marginBottom: true,
47 marginEnd: true,
48 marginHorizontal: true,
49 marginLeft: true,
50 marginRight: true,
51 marginStart: true,
52 marginTop: true,
53 marginVertical: true,
54 maxHeight: true,
55 maxWidth: true,
56 minHeight: true,
57 minWidth: true,
58 padding: true,
59 paddingBottom: true,
60 paddingEnd: true,
61 paddingHorizontal: true,
62 paddingLeft: true,
63 paddingRight: true,
64 paddingStart: true,
65 paddingTop: true,
66 paddingVertical: true,
67 right: true,
68 start: true,
69 top: true,
70 width: true,
71 zIndex: true,
72 borderBottomEndRadius: true,
73 borderBottomLeftRadius: true,
74 borderBottomRightRadius: true,
75 borderBottomStartRadius: true,
76 borderRadius: true,
77 borderTopEndRadius: true,
78 borderTopLeftRadius: true,
79 borderTopRightRadius: true,
80 borderTopStartRadius: true,
81 opacity: true,
82 elevation: true,
83 fontSize: true,
84 lineHeight: true,
85 textShadowRadius: true,
86 letterSpacing: true,
87 /* strings */
88 display: true,
89 backfaceVisibility: true,
90 overflow: true,
91 resizeMode: true,
92 fontStyle: true,
93 fontWeight: true,
94 textAlign: true,
95 textDecorationLine: true,
96 fontFamily: true,
97 textAlignVertical: true,
98 fontVariant: true,
99 textDecorationStyle: true,
100 textTransform: true,
101 writingDirection: true,
102 /* text color */
103 color: true,
104};
105
106function configureProps() {
107 ReanimatedModule.configureProps(
108 Object.keys(NATIVE_THREAD_PROPS_WHITELIST),
109 Object.keys(UI_THREAD_PROPS_WHITELIST)
110 );
111}
112
113export function addWhitelistedNativeProps(props) {
114 NATIVE_THREAD_PROPS_WHITELIST = {
115 ...NATIVE_THREAD_PROPS_WHITELIST,
116 ...props,
117 };
118 configureProps();
119}
120
121export function addWhitelistedUIProps(props) {
122 UI_THREAD_PROPS_WHITELIST = { ...UI_THREAD_PROPS_WHITELIST, ...props };
123 configureProps();
124}
125
126configureProps();