@@ -43,37 +43,45 @@ export default Base.extend({
4343 } ,
4444
4545 _init ( ) {
46- const scroll_container_y = dom . find_scroll_container ( this . el . parentElement , "y" ) ;
47- const scroll_container_x = dom . find_scroll_container ( this . el . parentElement , "x" ) ;
46+ const scroll_container_y = dom . find_scroll_container (
47+ this . el . parentElement ,
48+ "y" ,
49+ null
50+ ) ;
51+ const scroll_container_x = dom . find_scroll_container (
52+ this . el . parentElement ,
53+ "x" ,
54+ null
55+ ) ;
4856
4957 const pos = {
5058 top : dom . get_css_value ( this . el , "top" , true ) ,
5159 right : dom . get_css_value ( this . el , "right" , true ) ,
5260 bottom : dom . get_css_value ( this . el , "bottom" , true ) ,
5361 left : dom . get_css_value ( this . el , "left" , true ) ,
5462 } ;
55- const intersection_observer_config_y = {
63+ const intersection_observer_config = {
5664 threshold : [ 1 , 0.99 , 0.97 , 0.96 , 0.95 , 0.94 , 0.93 , 0.92 , 0.91 , 0.9 ] ,
57- root : scroll_container_y ,
5865 // add margin as inverted sticky positions.
5966 rootMargin : `${ - pos . top - 1 } px ${ - pos . right - 1 } px ${ - pos . bottom - 1 } px ${ - pos . left - 1 } px` , // prettier-ignore
6067 } ;
6168
6269 const observer_y = new IntersectionObserver (
6370 this . _intersection_observer_callback . bind ( this ) ,
64- intersection_observer_config_y
71+ {
72+ ...intersection_observer_config ,
73+ root : scroll_container_y ,
74+ }
6575 ) ;
6676 observer_y . observe ( this . el ) ;
6777
6878 if ( scroll_container_x !== scroll_container_y ) {
69- const intersection_observer_config_x = Object . assign (
70- { } ,
71- intersection_observer_config_y ,
72- { root : scroll_container_x }
73- ) ;
7479 const observer_x = new IntersectionObserver (
7580 this . _intersection_observer_callback . bind ( this ) ,
76- intersection_observer_config_x
81+ {
82+ ...intersection_observer_config ,
83+ root : scroll_container_x ,
84+ }
7785 ) ;
7886 observer_x . observe ( this . el ) ;
7987 }
0 commit comments