File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ const ImageBlurPreloader: FC<Props> = ({
38
38
prevMainAttributes . srcSet === mainAttributes . srcSet
39
39
) ;
40
40
41
- const _isDelayedBlur = useDelayed ( isMainImageChanged , BLUR_IMAGE_DELAY ) ;
41
+ // use isLoadingBlur to measure delay
42
+ const isDelayedBlur = useDelayed ( isLoadingBlur , BLUR_IMAGE_DELAY ) ;
42
43
43
44
// reset isLoading on main image change
44
45
useEffect ( ( ) => {
@@ -92,10 +93,13 @@ const ImageBlurPreloader: FC<Props> = ({
92
93
className = { cn (
93
94
'object-cover absolute top-0 left-0 size-full' ,
94
95
// important:
95
- // _!isLoadingBlur - don't hide main image until next blur image is loaded
96
- // isMainImageChanged - don't show main image while it's transitioning - solves flickering
97
- // isDelayedBlur - fixed blur delay
98
- ! isLoadingBlur && ( isLoadingMain || isMainImageChanged ) ? 'opacity-0' : 'opacity-100' ,
96
+ // must test remote, real world
97
+ // (!isLoadingBlur || isMainImageChanged) - must go together, blur is not ready, keep old main image
98
+ ( ! isLoadingBlur || isMainImageChanged ) &&
99
+ // (isLoadingMain || isDelayedBlur) - go together, show blur image
100
+ ( isLoadingMain || isDelayedBlur )
101
+ ? 'opacity-0'
102
+ : 'opacity-100' ,
99
103
className
100
104
) }
101
105
/>
You can’t perform that action at this time.
0 commit comments