@mpxjs/webpack-plugin 2.10.18-beta.13 → 2.10.18-beta.15
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.
- package/lib/runtime/components/react/dist/mpx-image.jsx +28 -2
- package/lib/runtime/components/react/dist/mpx-input.jsx +1 -0
- package/lib/runtime/components/react/mpx-image.tsx +28 -2
- package/lib/runtime/components/react/mpx-input.tsx +1 -0
- package/lib/runtime/components/react/mpx-section-list.tsx +0 -1
- package/lib/runtime/optionProcessorReact.js +5 -0
- package/package.json +1 -1
|
@@ -271,7 +271,31 @@ const Image = forwardRef((props, ref) => {
|
|
|
271
271
|
const onImageLoad = (evt) => {
|
|
272
272
|
evt.persist();
|
|
273
273
|
RNImage.getSize(src, (width, height) => {
|
|
274
|
-
|
|
274
|
+
// iPhone 8 等设备对缓存图 getSize 偶发返回 0,用 onLoad 事件里的真实尺寸兜底
|
|
275
|
+
if (!width || !height) {
|
|
276
|
+
const nativeEvent = evt.nativeEvent;
|
|
277
|
+
const source = nativeEvent.source;
|
|
278
|
+
width = (source && source.width) || nativeEvent.width || 0;
|
|
279
|
+
height = (source && source.height) || nativeEvent.height || 0;
|
|
280
|
+
// 布局模式下用真实尺寸同步 view(此时 useEffect 里的 getSize 也没拿到尺寸)
|
|
281
|
+
if (isLayoutMode && width && height && !state.current.ratio) {
|
|
282
|
+
state.current.imageWidth = width;
|
|
283
|
+
state.current.imageHeight = height;
|
|
284
|
+
state.current.ratio = height / width;
|
|
285
|
+
if (isWidthFixMode
|
|
286
|
+
? state.current.viewWidth
|
|
287
|
+
: isHeightFixMode
|
|
288
|
+
? state.current.viewHeight
|
|
289
|
+
: state.current.viewWidth && state.current.viewHeight) {
|
|
290
|
+
setRatio(state.current.ratio);
|
|
291
|
+
setImageWidth(width);
|
|
292
|
+
setImageHeight(height);
|
|
293
|
+
setViewSize(state.current.viewWidth, state.current.viewHeight, state.current.ratio);
|
|
294
|
+
setLoaded(true);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
bindload && bindload(getCustomEvent('load', evt, {
|
|
275
299
|
detail: { width, height },
|
|
276
300
|
layoutRef
|
|
277
301
|
}, props));
|
|
@@ -327,10 +351,12 @@ const Image = forwardRef((props, ref) => {
|
|
|
327
351
|
return renderImage(extendObject({
|
|
328
352
|
source: { uri: src },
|
|
329
353
|
resizeMode: resizeMode,
|
|
330
|
-
onLoad:
|
|
354
|
+
onLoad: onImageLoad,
|
|
331
355
|
onError: binderror && onImageError,
|
|
332
356
|
style: extendObject({
|
|
333
357
|
transformOrigin: 'left top',
|
|
358
|
+
// 布局模式下尺寸未知(ratio 为 0)前先隐藏,避免按默认高度闪一下(iPhone 8 getSize 返回 0 时尤其明显)
|
|
359
|
+
opacity: isLayoutMode && !ratio ? 0 : 1,
|
|
334
360
|
width: isCropMode ? imageWidth : '100%',
|
|
335
361
|
height: isCropMode ? imageHeight : '100%'
|
|
336
362
|
}, isCropMode ? modeStyle : {})
|
|
@@ -381,7 +381,31 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
381
381
|
const onImageLoad = (evt: NativeSyntheticEvent<ImageLoadEventData>) => {
|
|
382
382
|
evt.persist()
|
|
383
383
|
RNImage.getSize(src, (width: number, height: number) => {
|
|
384
|
-
|
|
384
|
+
// iPhone 8 等设备对缓存图 getSize 偶发返回 0,用 onLoad 事件里的真实尺寸兜底
|
|
385
|
+
if (!width || !height) {
|
|
386
|
+
const nativeEvent = evt.nativeEvent as any
|
|
387
|
+
const source = nativeEvent.source
|
|
388
|
+
width = (source && source.width) || nativeEvent.width || 0
|
|
389
|
+
height = (source && source.height) || nativeEvent.height || 0
|
|
390
|
+
// 布局模式下用真实尺寸同步 view(此时 useEffect 里的 getSize 也没拿到尺寸)
|
|
391
|
+
if (isLayoutMode && width && height && !state.current.ratio) {
|
|
392
|
+
state.current.imageWidth = width
|
|
393
|
+
state.current.imageHeight = height
|
|
394
|
+
state.current.ratio = height / width
|
|
395
|
+
if (isWidthFixMode
|
|
396
|
+
? state.current.viewWidth
|
|
397
|
+
: isHeightFixMode
|
|
398
|
+
? state.current.viewHeight
|
|
399
|
+
: state.current.viewWidth && state.current.viewHeight) {
|
|
400
|
+
setRatio(state.current.ratio)
|
|
401
|
+
setImageWidth(width)
|
|
402
|
+
setImageHeight(height)
|
|
403
|
+
setViewSize(state.current.viewWidth!, state.current.viewHeight!, state.current.ratio)
|
|
404
|
+
setLoaded(true)
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
bindload && bindload!(
|
|
385
409
|
getCustomEvent(
|
|
386
410
|
'load',
|
|
387
411
|
evt,
|
|
@@ -486,11 +510,13 @@ const Image = forwardRef<HandlerRef<RNImage, ImageProps>, ImageProps>((props, re
|
|
|
486
510
|
{
|
|
487
511
|
source: { uri: src },
|
|
488
512
|
resizeMode: resizeMode,
|
|
489
|
-
onLoad:
|
|
513
|
+
onLoad: onImageLoad,
|
|
490
514
|
onError: binderror && onImageError,
|
|
491
515
|
style: extendObject(
|
|
492
516
|
{
|
|
493
517
|
transformOrigin: 'left top',
|
|
518
|
+
// 布局模式下尺寸未知(ratio 为 0)前先隐藏,避免按默认高度闪一下(iPhone 8 getSize 返回 0 时尤其明显)
|
|
519
|
+
opacity: isLayoutMode && !ratio ? 0 : 1,
|
|
494
520
|
width: isCropMode ? imageWidth : '100%',
|
|
495
521
|
height: isCropMode ? imageHeight : '100%'
|
|
496
522
|
},
|
|
@@ -120,7 +120,6 @@ const _SectionList = forwardRef<any, SectionListProps>((props = {}, ref) => {
|
|
|
120
120
|
const scrollViewRef = useRef<any>(null)
|
|
121
121
|
const sectionListGestureRef = useRef<any>()
|
|
122
122
|
|
|
123
|
-
|
|
124
123
|
const indexMap = useRef<{ [key: string]: string | number }>({})
|
|
125
124
|
|
|
126
125
|
const reverseIndexMap = useRef<{ [key: string]: number }>({})
|
|
@@ -14,6 +14,11 @@ export function getComponent (component, extendOptions) {
|
|
|
14
14
|
// eslint-disable-next-line
|
|
15
15
|
if (extendOptions && !component.__mpxExtended) {
|
|
16
16
|
extend(component, extendOptions, { __mpxExtended: true })
|
|
17
|
+
const render = (component.type && component.type.render) || component.render
|
|
18
|
+
const displayName = extendOptions.displayName || component.displayName
|
|
19
|
+
if (render && displayName && !render.displayName) {
|
|
20
|
+
render.displayName = displayName
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
return component
|
|
19
24
|
}
|