'typescript - detect if the div is overflow with text (not working if -webkit-scrollbar display is set to none)

Below mentioned code works fine if the scrollbar is visible. But it stops working once i use

::-webkit-scrollbar {display: none;}

and

-ms-overflow-style: none; scrollbar-width: none;

MY working code if scrollbar is visible

Html

    <div #theElementYouWantToCheck><button *ngIf="checkOverflow(theElementYouWantToCheck)">More</button</div>

Ts

   checkOverflow (element) {
return element.offsetHeight < element.scrollHeight ||
       element.offsetWidth < element.scrollWidth;}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source