added method to allow the animation duration to be set programmatically