This is a rewrite of my plugin Custom Gravity