export default function ( lastKnownScrollY = 0 , currentScrollY = 0 , disable ? , pinStart ? , downTolerance ? , upTolerance ? , state ? , height ? ) { const scrollDirection = currentScrollY >= lastKnownScrollY ? 'down' : 'up' ; const distanceScrolled = Math . abs ( currentScrollY - lastKnownScrollY ) ; if ( disable ) { return { action : 'none' , scrollDirection , distanceScrolled , } ; } else if ( currentScrollY <= pinStart && state !== 'unfixed' ) { return { action : 'unfix' , scrollDirection , distanceScrolled , } ; } else if ( currentScrollY <= height && scrollDirection === 'down' && state === 'unfixed' ) { return { action : 'none' , scrollDirection , distanceScrolled , } ; } else if ( scrollDirection === 'down' && [ 'pinned' , 'unfixed' ] . indexOf ( state ) >= 0 && currentScrollY > height + pinStart && distanceScrolled > downTolerance ) { return { action : 'unpin' , scrollDirection , distanceScrolled , } ; } else if ( scrollDirection === 'up' && distanceScrolled > upTolerance && [ 'pinned' , 'unfixed' ] . indexOf ( state ) < 0 ) { return { action : 'pin' , scrollDirection , distanceScrolled , } ; } else if ( scrollDirection === 'up' && currentScrollY <= height && [ 'pinned' , 'unfixed' ] . indexOf ( state ) < 0 ) { return { action : 'pin' , scrollDirection , distanceScrolled , } ; } else { return { action : 'none' , scrollDirection , distanceScrolled , } ; } }