[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

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


Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1