code: function applyMargins(targetRect, margins) {
      margins = margins.map((margin, index) => {
          let value = margin.value;
  
          if (!margin.pixels) {
              value *= index % 2 ? targetRect.width : targetRect.height;
          }
  
          return value;
      });
  
      const result = {
          top: targetRect.top - margins[0],
          right: targetRect.right + margins[1],
          bottom: targetRect.bottom + margins[2],
          left: targetRect.left - margins[3]
      };
  
      result.width = result.right - result.left;
      result.height = result.bottom - result.top;
  
      return result;
  }
docs: Creates new rectangle from provided one whose
  dimensions will be modified by applying margins
  defined in a form of [[value: Number, pixels: Boolean], ...].
  
  @param {ClientRect} targetRect - Initial rectangle.
  @param {Array<Array>} margins - Margins data.
  @returns {ClientRect} Modified rectangle.