added the onSnap callback for easier integration