I've tried to merge different behaviours found online. Here is [the result](https://gist.github.com/Polyterative/1b24f5423871a4d15dd5d00c36317328)