File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ describe ( 'Scroll' , ( ) => {
2+ beforeEach ( ( ) => {
3+ cy . visit ( '/examples/scroll/' , { } ) ;
4+ } ) ;
5+
6+ describe ( 'tether stays near scrollbar' , ( ) => {
7+ it ( 'appears on scroll and stays in fixed position' , ( ) => {
8+ let tetherFixed ;
9+ let tetherOffsetTop ;
10+
11+ cy . get ( '.tether-target' ) . and ( el => {
12+ // set the initial position coords
13+ tetherFixed = el . find ( '.pointer' ) ;
14+ // starting point is 9px from top of document
15+ tetherOffsetTop = tetherFixed [ 0 ] . getBoundingClientRect ( ) . top - 9 ;
16+
17+ expect ( el ) . to . contain ( '.pointer' ) ;
18+ } ) ;
19+ cy . get ( '.pointer' ) . should ( 'have.css' , 'opacity' , '0' ) ;
20+
21+ cy . scrollTo ( 0 , 1500 ) ;
22+
23+ cy . get ( '.pointer' ) . should ( 'have.css' , 'opacity' , '1' ) ;
24+ cy . get ( '.pointer' ) . and ( el => {
25+ const vpOffset = el [ 0 ] . getBoundingClientRect ( ) ;
26+ // we measure from top minus scrolled coords
27+ expect ( vpOffset . top + window . pageYOffset ) . to . equal ( tetherOffsetTop ) ;
28+ } ) ;
29+ } ) ;
30+ } ) ;
31+ } ) ;
You can’t perform that action at this time.
0 commit comments