It seems this sample code cover your needs: https://codepen.io/codeaaron/pen/bBpZdx

But it's kind off topic here 😉