basic.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.basic = void 0;
  6. var _my = require("../../__antmove/api/index.js")(my);
  7. var wx = _my;
  8. function Behavior(behavior) {
  9. behavior.$id = Number(new Date()) + String(Math.random()).substring(2, 7);
  10. return behavior;
  11. }
  12. var basic = Behavior({
  13. methods: {
  14. $emit: function $emit(name, detail, options) {
  15. this.triggerEvent(name, detail, options);
  16. },
  17. set: function set(data, callback) {
  18. this.setData(data, callback);
  19. return new Promise(function (resolve) {
  20. return wx.nextTick(resolve);
  21. });
  22. },
  23. getRect: function getRect(selector, all) {
  24. var _this = this;
  25. return new Promise(function (resolve) {
  26. wx.createSelectorQuery()["in"](_this)[all ? "selectAll" : "select"](selector).boundingClientRect(function (rect) {
  27. if (all && Array.isArray(rect) && rect.length) {
  28. resolve(rect);
  29. }
  30. if (!all && rect) {
  31. resolve(rect);
  32. }
  33. }).exec();
  34. });
  35. }
  36. }
  37. });
  38. exports.basic = basic;