fix bug on snapping

  the value chosen as anchor for snapping is now the closest anchor