@@ -38,33 +38,32 @@ const StdcmLoader = ({
38
38
innerHeight - launchButtonRef . current . getBoundingClientRect ( ) . top >
39
39
LOADER_HEIGHT + LOADER_BOTTOM_OFFSET ;
40
40
41
- if ( launchButtonRef . current && isLoaderFitting ) {
41
+ // Loader doesn't fit between the bottom of the form and bottom of the viewport
42
+ if ( ! isLoaderFitting ) {
42
43
setLoaderStatus ( {
43
44
firstLaunch : false ,
44
- status : 'absolute' ,
45
- } ) ;
46
- } else {
47
- setLoaderStatus ( {
48
- firstLaunch : false ,
49
- status : 'sticky' ,
45
+ status : 'fixedBottom' ,
50
46
} ) ;
47
+ return ;
51
48
}
52
49
53
50
const currentFormHeight = loaderRef . current . parentElement ! . clientHeight ;
54
51
const shouldLoaderStickTop =
55
52
scrollY > currentFormHeight + FORM_TOP_OFFSET - LAUNCH_BUTTON_HEIGHT ;
56
53
54
+ // Loader reaches the top of the screen minus its top offset
57
55
if ( shouldLoaderStickTop ) {
58
56
setLoaderStatus ( {
59
57
firstLaunch : false ,
60
- status : 'fixed' ,
61
- } ) ;
62
- } else if ( loaderStatus . status === 'fixed' ) {
63
- setLoaderStatus ( {
64
- firstLaunch : false ,
65
- status : 'absolute' ,
58
+ status : 'fixedTop' ,
66
59
} ) ;
60
+ return ;
67
61
}
62
+
63
+ setLoaderStatus ( {
64
+ firstLaunch : false ,
65
+ status : 'absolute' ,
66
+ } ) ;
68
67
} ;
69
68
70
69
window . addEventListener ( 'scroll' , handleScroll ) ;
@@ -77,11 +76,11 @@ const StdcmLoader = ({
77
76
< div
78
77
ref = { loaderRef }
79
78
className = { cx ( `stdcm-loader` , {
80
- fixed : loaderStatus . status === 'fixed ' ,
79
+ ' fixed-top' : loaderStatus . status === 'fixedTop ' ,
81
80
absolute : loaderStatus . status === 'absolute' ,
82
81
'with-fade-in-animation' : loaderStatus . status === 'absolute' && loaderStatus . firstLaunch ,
83
- sticky : loaderStatus . status === 'sticky ' ,
84
- 'with-slide-animation' : loaderStatus . status === 'sticky ' && loaderStatus . firstLaunch ,
82
+ 'fixed-bottom' : loaderStatus . status === 'fixedBottom ' ,
83
+ 'with-slide-animation' : loaderStatus . status === 'fixedBottom ' && loaderStatus . firstLaunch ,
85
84
} ) }
86
85
>
87
86
< div className = "stdcm-loader__wrapper" >
0 commit comments