inView
inView is an imperative wrapper around IntersectionObserver. The callback runs when an element
enters; return a cleanup function to run when it leaves.
import { inView } from 'motion-solidjs'
const stop = inView(
'.card',
(info) => {
info.target.classList.add('seen')
return () => info.target.classList.remove('seen') // on exit
},
{ amount: 0.5, margin: '0px' },
)
// later
stop()
Card 1
Card 2
Card 3
Card 4
Card 5
Card 6
Card 7
Card 8
For a reactive boolean, see createInView.