[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/vendor/ -> wp-polyfill-dom-rect.js (source)

   1  (function (global) {
   2  	function number(v) {
   3          return v === undefined ? 0 : Number(v);
   4      }
   5  
   6   	function different(u, v) {
   7          return u !== v && !(isNaN(u) && isNaN(v));
   8      }
   9  
  10   	function DOMRect(xArg, yArg, wArg, hArg) {
  11          var x, y, width, height, left, right, top, bottom;
  12  
  13           x = number(xArg);
  14          y = number(yArg);
  15          width = number(wArg);
  16          height = number(hArg);
  17  
  18           Object.defineProperties(this, {
  19              x: {
  20                  get: function () { return x; },
  21                  set: function (newX) {
  22                      if (different(x, newX)) {
  23                          x = newX;
  24                          left = right = undefined;
  25                      }
  26                  },
  27                  enumerable: true
  28              },
  29              y: {
  30                  get: function () { return y; },
  31                  set: function (newY) {
  32                      if (different(y, newY)) {
  33                          y = newY;
  34                          top = bottom = undefined;
  35                      }
  36                  },
  37                  enumerable: true
  38              },
  39              width: {
  40                  get: function () { return width; },
  41                  set: function (newWidth) {
  42                      if (different(width, newWidth)) {
  43                          width = newWidth;
  44                          left = right = undefined;
  45                      }
  46                  },
  47                  enumerable: true
  48              },
  49              height: {
  50                  get: function () { return height; },
  51                  set: function (newHeight) {
  52                      if (different(height, newHeight)) {
  53                          height = newHeight;
  54                          top = bottom = undefined;
  55                      }
  56                  },
  57                  enumerable: true
  58              },
  59              left: {
  60                  get: function () {
  61                      if (left === undefined) {
  62                          left = x + Math.min(0, width);
  63                      }
  64                      return left;
  65                  },
  66                  enumerable: true
  67              },
  68              right: {
  69                  get: function () {
  70                      if (right === undefined) {
  71                          right = x + Math.max(0, width);
  72                      }
  73                      return right;
  74                  },
  75                  enumerable: true
  76              },
  77              top: {
  78                  get: function () {
  79                      if (top === undefined) {
  80                          top = y + Math.min(0, height);
  81                      }
  82                      return top;
  83                  },
  84                  enumerable: true
  85              },
  86              bottom: {
  87                  get: function () {
  88                      if (bottom === undefined) {
  89                          bottom = y + Math.max(0, height);
  90                      }
  91                      return bottom;
  92                  },
  93                  enumerable: true
  94              }
  95          });
  96      }
  97  
  98       global.DOMRect = DOMRect;
  99  }(this));


Generated : Fri Apr 26 08:20:02 2024 Cross-referenced by PHPXref