Interactive slider prototype

I would like to create a slider, and the block is the middle position, when I press and drag it, the block follows my mouse location but always keep horizontal. But when I release the block, the block can automatic go back to middle position. I wonder do you know how to do this or has the similar example can show?
Thanks for your support.