tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

vertical-scroll.js (615B)


      1 function rectMaxY(rect) {
      2  return rect.height + rect.y;
      3 }
      4 
      5 function rectMaxX(rect) {
      6  return rect.width + rect.x;
      7 }
      8 
      9 function isEmptyRect(rect) {
     10  return !rect.width || !rect.height;
     11 }
     12 
     13 // Returns true if the given rectangles intersect.
     14 function rects_intersect(rect1, rect2) {
     15  if (isEmptyRect(rect1) || isEmptyRect(rect2))
     16    return false;
     17  return rect1.x < rectMaxX(rect2) &&
     18         rect2.x < rectMaxX(rect1) &&
     19         rect1.y < rectMaxY(rect2) &&
     20         rect2.y < rectMaxY(rect1);
     21 }
     22 
     23 function rectToString(rect) {
     24  return `Location: (${rect.x}, ${rect.y}) Size: (${rect.width}, ${rect.height})`;
     25 }