react-native-fast-image 9.0.1 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,10 +23,12 @@ import com.facebook.react.uimanager.SimpleViewManager;
|
|
|
23
23
|
import com.facebook.react.bridge.ReactContext;
|
|
24
24
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
25
25
|
import com.facebook.react.uimanager.PixelUtil;
|
|
26
|
+
import com.facebook.react.uimanager.PointerEvents;
|
|
26
27
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
27
28
|
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
|
28
29
|
|
|
29
30
|
import java.util.List;
|
|
31
|
+
import java.util.Locale;
|
|
30
32
|
import java.util.Map;
|
|
31
33
|
import java.util.WeakHashMap;
|
|
32
34
|
|
|
@@ -82,6 +84,16 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
82
84
|
.getResourceDrawable(view.getContext(), source));
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
// React Native's View manager handles pointerEvents; a SimpleViewManager
|
|
88
|
+
// doesn't. Parsed here: PointerEvents.parsePointerEvents isn't in every
|
|
89
|
+
// supported React Native version.
|
|
90
|
+
@ReactProp(name = "pointerEvents")
|
|
91
|
+
public void setPointerEvents(FastImageViewWithUrl view, @Nullable String pointerEvents) {
|
|
92
|
+
view.setPointerEvents(pointerEvents == null
|
|
93
|
+
? PointerEvents.AUTO
|
|
94
|
+
: PointerEvents.valueOf(pointerEvents.toUpperCase(Locale.US).replace('-', '_')));
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
@ReactProp(name = "tintColor", customType = "Color")
|
|
86
98
|
public void setTintColor(FastImageViewWithUrl view, @Nullable Integer color) {
|
|
87
99
|
if (color == null) {
|
|
@@ -43,6 +43,8 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
43
43
|
import com.facebook.react.bridge.ReadableMap;
|
|
44
44
|
import com.facebook.react.bridge.WritableMap;
|
|
45
45
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
46
|
+
import com.facebook.react.uimanager.PointerEvents;
|
|
47
|
+
import com.facebook.react.uimanager.ReactPointerEventsView;
|
|
46
48
|
|
|
47
49
|
import java.util.ArrayList;
|
|
48
50
|
import java.util.Collections;
|
|
@@ -51,7 +53,7 @@ import java.util.Map;
|
|
|
51
53
|
|
|
52
54
|
import javax.annotation.Nonnull;
|
|
53
55
|
|
|
54
|
-
class FastImageViewWithUrl extends AppCompatImageView {
|
|
56
|
+
class FastImageViewWithUrl extends AppCompatImageView implements ReactPointerEventsView {
|
|
55
57
|
private boolean mNeedsReload = false;
|
|
56
58
|
private ReadableMap mSource = null;
|
|
57
59
|
private Drawable mDefaultSource = null;
|
|
@@ -66,6 +68,20 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
66
68
|
this.requestManager = requestManager;
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
// FastImage sends "none" when it has pointerEvents="box-none" (the image
|
|
72
|
+
// is part of the box, which doesn't take touches). React Native's touch
|
|
73
|
+
// handling only reads pointerEvents from a ReactPointerEventsView.
|
|
74
|
+
private PointerEvents mPointerEvents = PointerEvents.AUTO;
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public PointerEvents getPointerEvents() {
|
|
78
|
+
return mPointerEvents;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void setPointerEvents(PointerEvents pointerEvents) {
|
|
82
|
+
mPointerEvents = pointerEvents;
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
public void setSource(@Nullable ReadableMap source) {
|
|
70
86
|
mNeedsReload = true;
|
|
71
87
|
mPropSource = source;
|
package/dist/index.cjs.js
CHANGED
|
@@ -111,13 +111,31 @@ function withoutCache(source) {
|
|
|
111
111
|
const { cache: _cache, ...rest } = source || {};
|
|
112
112
|
return rest;
|
|
113
113
|
}
|
|
114
|
-
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, ...viewProps }) {
|
|
114
|
+
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, hitSlop, onStartShouldSetResponder, onStartShouldSetResponderCapture, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderGrant, onResponderReject, onResponderStart, onResponderMove, onResponderEnd, onResponderRelease, onResponderTerminationRequest, onResponderTerminate, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onTouchEndCapture, ...viewProps }) {
|
|
115
115
|
const { onClick, ...props } = viewProps;
|
|
116
116
|
const fallbackResult = (0, react.useRef)(void 0);
|
|
117
117
|
const wrapperProps = {
|
|
118
118
|
onLayout,
|
|
119
119
|
onClick,
|
|
120
|
-
pointerEvents
|
|
120
|
+
pointerEvents,
|
|
121
|
+
hitSlop,
|
|
122
|
+
onStartShouldSetResponder,
|
|
123
|
+
onStartShouldSetResponderCapture,
|
|
124
|
+
onMoveShouldSetResponder,
|
|
125
|
+
onMoveShouldSetResponderCapture,
|
|
126
|
+
onResponderGrant,
|
|
127
|
+
onResponderReject,
|
|
128
|
+
onResponderStart,
|
|
129
|
+
onResponderMove,
|
|
130
|
+
onResponderEnd,
|
|
131
|
+
onResponderRelease,
|
|
132
|
+
onResponderTerminationRequest,
|
|
133
|
+
onResponderTerminate,
|
|
134
|
+
onTouchStart,
|
|
135
|
+
onTouchMove,
|
|
136
|
+
onTouchEnd,
|
|
137
|
+
onTouchCancel,
|
|
138
|
+
onTouchEndCapture
|
|
121
139
|
};
|
|
122
140
|
const imageProps = {
|
|
123
141
|
...props,
|
|
@@ -248,7 +266,6 @@ const styles = react_native.StyleSheet.create({
|
|
|
248
266
|
},
|
|
249
267
|
imageContainer: { overflow: "hidden" }
|
|
250
268
|
});
|
|
251
|
-
const FastImageWithRef = FastImageComponent;
|
|
252
269
|
/**
|
|
253
270
|
* An image with content on top of it, like React Native's `ImageBackground`: a
|
|
254
271
|
* view that the image fills, with the children on top. Use it rather than
|
|
@@ -261,7 +278,7 @@ const FastImageBackground = (0, react.forwardRef)(({ style, imageStyle, imageRef
|
|
|
261
278
|
importantForAccessibility,
|
|
262
279
|
style,
|
|
263
280
|
ref
|
|
264
|
-
}, /* @__PURE__ */ react.default.createElement(
|
|
281
|
+
}, /* @__PURE__ */ react.default.createElement(FastImageComponent, {
|
|
265
282
|
...props,
|
|
266
283
|
importantForAccessibility,
|
|
267
284
|
style: [react_native.StyleSheet.absoluteFill, imageStyle],
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ColorValue, StyleProp, ViewStyle, ImageRequireSource, AccessibilityProps, ViewProps } from 'react-native';
|
|
2
|
+
import { ColorValue, View, StyleProp, ViewStyle, ImageRequireSource, AccessibilityProps, ViewProps } from 'react-native';
|
|
3
3
|
import { cacheControl, priority, resizeMode } from './constants';
|
|
4
4
|
/** How the image fits the view: see [`resizeMode`](#resizemode). */
|
|
5
5
|
export type ResizeMode = 'contain' | 'cover' | 'stretch' | 'center' | 'repeat';
|
|
@@ -499,6 +499,7 @@ export interface FastImageProps extends AccessibilityProps, ViewProps {
|
|
|
499
499
|
*/
|
|
500
500
|
children?: React.ReactNode;
|
|
501
501
|
}
|
|
502
|
+
type ViewRef = React.ElementRef<typeof View>;
|
|
502
503
|
/** A preloaded source that loaded (and is now cached). */
|
|
503
504
|
export interface PreloadSuccess {
|
|
504
505
|
/** The source's uri. */
|
|
@@ -556,7 +557,7 @@ export interface FastImageStaticProperties {
|
|
|
556
557
|
*/
|
|
557
558
|
configureCache: (limits?: CacheLimits) => Promise<CacheState>;
|
|
558
559
|
}
|
|
559
|
-
declare const FastImage: React.
|
|
560
|
+
declare const FastImage: React.ForwardRefExoticComponent<FastImageProps & React.RefAttributes<ViewRef>> & FastImageStaticProperties;
|
|
560
561
|
export interface FastImageBackgroundProps extends Omit<FastImageProps, 'style' | 'children'> {
|
|
561
562
|
/** The container's style; the image fills it. */
|
|
562
563
|
style?: StyleProp<ViewStyle>;
|
|
@@ -574,5 +575,5 @@ export interface FastImageBackgroundProps extends Omit<FastImageProps, 'style' |
|
|
|
574
575
|
* (the image will be a single native view). The other props go to the image;
|
|
575
576
|
* the ref is the view's.
|
|
576
577
|
*/
|
|
577
|
-
export declare const FastImageBackground: React.
|
|
578
|
+
export declare const FastImageBackground: React.ForwardRefExoticComponent<FastImageBackgroundProps & React.RefAttributes<ViewRef>>;
|
|
578
579
|
export default FastImage;
|
package/dist/index.js
CHANGED
|
@@ -84,13 +84,31 @@ function withoutCache(source) {
|
|
|
84
84
|
const { cache: _cache, ...rest } = source || {};
|
|
85
85
|
return rest;
|
|
86
86
|
}
|
|
87
|
-
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, ...viewProps }) {
|
|
87
|
+
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, hitSlop, onStartShouldSetResponder, onStartShouldSetResponderCapture, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderGrant, onResponderReject, onResponderStart, onResponderMove, onResponderEnd, onResponderRelease, onResponderTerminationRequest, onResponderTerminate, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onTouchEndCapture, ...viewProps }) {
|
|
88
88
|
const { onClick, ...props } = viewProps;
|
|
89
89
|
const fallbackResult = useRef(void 0);
|
|
90
90
|
const wrapperProps = {
|
|
91
91
|
onLayout,
|
|
92
92
|
onClick,
|
|
93
|
-
pointerEvents
|
|
93
|
+
pointerEvents,
|
|
94
|
+
hitSlop,
|
|
95
|
+
onStartShouldSetResponder,
|
|
96
|
+
onStartShouldSetResponderCapture,
|
|
97
|
+
onMoveShouldSetResponder,
|
|
98
|
+
onMoveShouldSetResponderCapture,
|
|
99
|
+
onResponderGrant,
|
|
100
|
+
onResponderReject,
|
|
101
|
+
onResponderStart,
|
|
102
|
+
onResponderMove,
|
|
103
|
+
onResponderEnd,
|
|
104
|
+
onResponderRelease,
|
|
105
|
+
onResponderTerminationRequest,
|
|
106
|
+
onResponderTerminate,
|
|
107
|
+
onTouchStart,
|
|
108
|
+
onTouchMove,
|
|
109
|
+
onTouchEnd,
|
|
110
|
+
onTouchCancel,
|
|
111
|
+
onTouchEndCapture
|
|
94
112
|
};
|
|
95
113
|
const imageProps = {
|
|
96
114
|
...props,
|
|
@@ -221,7 +239,6 @@ const styles = StyleSheet.create({
|
|
|
221
239
|
},
|
|
222
240
|
imageContainer: { overflow: "hidden" }
|
|
223
241
|
});
|
|
224
|
-
const FastImageWithRef = FastImageComponent;
|
|
225
242
|
/**
|
|
226
243
|
* An image with content on top of it, like React Native's `ImageBackground`: a
|
|
227
244
|
* view that the image fills, with the children on top. Use it rather than
|
|
@@ -234,7 +251,7 @@ const FastImageBackground = forwardRef(({ style, imageStyle, imageRef, children,
|
|
|
234
251
|
importantForAccessibility,
|
|
235
252
|
style,
|
|
236
253
|
ref
|
|
237
|
-
}, /* @__PURE__ */ React.createElement(
|
|
254
|
+
}, /* @__PURE__ */ React.createElement(FastImageComponent, {
|
|
238
255
|
...props,
|
|
239
256
|
importantForAccessibility,
|
|
240
257
|
style: [StyleSheet.absoluteFill, imageStyle],
|