Most of the credits should go to Michael Matuzak who did something similar and which I used as a starter for the JS demo:
<a href="https://www.youtube.com/watch?v=NiOW-swy2Ys" rel="nofollow">https://www.youtube.com/watch?v=NiOW-swy2Ys</a>