Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

click.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. async function click(options) {
  4. if (typeof options === 'undefined') {
  5. return this.elementClick(this.elementId);
  6. }
  7. if (typeof options !== 'object' || Array.isArray(options)) {
  8. throw new TypeError('Options must be an object');
  9. }
  10. let { button = 0, x: xoffset = 0, y: yoffset = 0 } = options || {};
  11. if (typeof xoffset !== 'number'
  12. || typeof yoffset !== 'number'
  13. || !Number.isInteger(xoffset)
  14. || !Number.isInteger(yoffset)) {
  15. throw new TypeError('Coördinates must be integers');
  16. }
  17. if (button === 'left') {
  18. button = 0;
  19. }
  20. if (button === 'middle') {
  21. button = 1;
  22. }
  23. if (button === 'right') {
  24. button = 2;
  25. }
  26. if (![0, 1, 2].includes(button)) {
  27. throw new Error('Button type not supported.');
  28. }
  29. if (this.isW3C) {
  30. await this.performActions([{
  31. type: 'pointer',
  32. id: 'pointer1',
  33. parameters: {
  34. pointerType: 'mouse'
  35. },
  36. actions: [{
  37. type: 'pointerMove',
  38. origin: this,
  39. x: xoffset,
  40. y: yoffset
  41. }, {
  42. type: 'pointerDown',
  43. button
  44. }, {
  45. type: 'pointerUp',
  46. button
  47. }]
  48. }]);
  49. return this.releaseActions();
  50. }
  51. const { width, height } = await this.getElementSize(this.elementId);
  52. await this.moveToElement(this.elementId, xoffset + (width / 2), yoffset + (height / 2));
  53. return this.positionClick(button);
  54. }
  55. exports.default = click;