You need to improve to a pop-up prompt is not skipped each time?

Hello! There is a hint that there is js for this prompt, which as planned should: If die is beyond the visible area of the screen, ie tooltip.getBoundingClientRect().left < 0, then the die is added to the class 'm-left'. Now the class is added and then removed, and so on. What value I need to zapominat in the condition if (posLeft < 0)?
And another question, what I need to compare the window.innerWidth to determine that the die is not beyond the right edge of the screen? Now for example I put posLeft + tooltip.clientWidth + 26 it seems to be working, but not always, which calculation should be there? Please help to understand.

Link to example
April 19th 20 at 12:09
2 answers
April 19th 20 at 12:11
hammer) put tippy
April 19th 20 at 12:13
In such situations, it is easier to use the finished product: https://atomiks.github.io/tippyjs/

Easy setup and installation. Works perfectly. You can apply your styles + a bunch of features right out of the box.

Find more questions by tags JavaScript