Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Solobea#5719 - Part of Popup Positioning Code

a guest Mar 31st, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let ctxMenuButtonIds = [/*"clickHere",*/
  2.  {name: "topNavbar-section-one",},
  3.  {name: "breadcrumb-2-d", fixes: ['horizontalOffset', 'verticalOffset'],
  4.    offsetH: 'calc(0px - (calc(pWidth - bWidth)*0.5))', offsetV: 'calc(bHeight + 10px)' },
  5.  {name: "breadcrumb-3-d", fixes: ['horizontalOffset', 'verticalOffset'],
  6.    offsetH: 'calc(0px - (calc(pWidth - bWidth)*0.5))', offsetV: 'calc(bHeight + 10px)' },
  7.  {name: "breadcrumb-4-d", fixes: ['horizontalOffset', 'verticalOffset'],
  8.    offsetH: 'calc(0px - (calc(pWidth - bWidth)*0.5))', offsetV: 'calc(bHeight + 10px)' },
  9. ];
  10.  
  11. //...
  12.  
  13.  
  14.  
  15.         let buttonOffsetInfo = getOffset(btn)
  16.  
  17.         popup.classList.remove("popup-showing");
  18.         popup.classList.add("popup-showing");
  19.  
  20.         //Display needs to be showing otherwise offsetX and offsetY are nothing
  21.  
  22.         if (info.fixes && info.fixes.includes('horizontalOffset') && info.offsetH) {
  23.  
  24.           let posX_b = buttonOffsetInfo.left
  25.           let width_b = btn.offsetWidth
  26.  
  27.           let calc_string = info.offsetH
  28.           console.log('width_b: '+width_b)
  29.           calc_string = calc_string.replace(/bWidth/g, width_b+'px')
  30.           calc_string = calc_string.replace(/pWidth/g, popup.offsetWidth+'px')
  31.  
  32.           // NOTE: NOTE - Display is hidden, so won't width be 0?
  33.  
  34.           //console.log(calc_string)
  35.  
  36.           console.log(`calc(${posX_b}px + ${calc_string})`)
  37.  
  38.           popup.style.left = `calc(${posX_b}px + ${calc_string})`
  39.  
  40.         } else popup.style.left = `${position.x + 3}px`;
  41.  
  42.         if (info.fixes && info.fixes.includes('verticalOffset') && info.offsetV) {
  43.  
  44.           let posY_b = buttonOffsetInfo.top
  45.           let height_b = btn.offsetHeight
  46.  
  47.           let calc_string = info.offsetV
  48.           calc_string = calc_string.replace(/bHeight/g, height_b+'px')
  49.           calc_string = calc_string.replace(/pHeight/g, popup.offsetHeight+'px')
  50.  
  51.           //console.log(calc_string)
  52.  
  53.           console.log(`calc(${posY_b}px + ${calc_string})`)
  54.  
  55.           popup.style.top = `calc(${posY_b}px + ${calc_string})`
  56.  
  57.         } else popup.style.top = `${position.y + 3}px`;
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