SHARE
TWEET

Untitled

a guest Dec 6th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public componentDidMount() {
  2.     this.modalVisibilityHandler('image');
  3.     this.modalVisibilityHandler('emoji');
  4.     this.modalVisibilityHandler('colorpicker');
  5.     this.modalVisibilityHandler('link');
  6.     this.modalVisibilityHandler('embedded');
  7.   }
  8.  
  9.   public modalVisibilityHandler = (selector: string) => {
  10.     const modalWrapper = document.getElementsByClassName(`rdw-${selector}-wrapper`)[0];
  11.     if (modalWrapper) {
  12.       modalWrapper.addEventListener('mouseup', () => {
  13.         setTimeout(() => {
  14.           const modal = document.getElementsByClassName(`rdw-${selector}-modal`)[0];
  15.           if (modal) {
  16.             if (modal.getBoundingClientRect().right > window.innerWidth) {
  17.               (modal as HTMLElement).style.left = `${window.innerWidth -
  18.                 modal.getBoundingClientRect().right}px`;
  19.             }
  20.           }
  21.         }, 50);
  22.       });
  23.     }
  24.   };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top