Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

31 řádky
714 B

  1. 'use strict';
  2. /**
  3. * Copyright (c) 2013-present, Facebook, Inc.
  4. *
  5. * This source code is licensed under the MIT license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. *
  8. * @typechecks
  9. */
  10. var getElementRect = require('./getElementRect');
  11. /**
  12. * Gets an element's position in pixels relative to the viewport. The returned
  13. * object represents the position of the element's top left corner.
  14. *
  15. * @param {DOMElement} element
  16. * @return {object}
  17. */
  18. function getElementPosition(element) {
  19. var rect = getElementRect(element);
  20. return {
  21. x: rect.left,
  22. y: rect.top,
  23. width: rect.right - rect.left,
  24. height: rect.bottom - rect.top
  25. };
  26. }
  27. module.exports = getElementPosition;