added beforeSnap and afterSnap callbacks