wechat.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { __assign, __rest } from "tslib";
  2. import { platform } from '../_util/platform';
  3. export function transformOptions(original) {
  4. if (platform() === 'wechat') {
  5. var props = original.props, didMount_1 = original.didMount, didUpdate = original.didUpdate, rest = __rest(original, ["props", "didMount", "didUpdate"]);
  6. return __assign(__assign({}, rest), { properties: transformProperties(props), lifetimes: {
  7. attached: function () {
  8. return didMount_1.call(this);
  9. },
  10. }, observers: {
  11. 'damping, swiped': function () {
  12. this.setData({
  13. swipeX: 0,
  14. swipedR: false,
  15. swipedL: false,
  16. tapTypeL: '',
  17. tapTypeR: '',
  18. });
  19. },
  20. 'elasticity': function (elasticity) {
  21. this.setData({
  22. swipeX: 0,
  23. swipedR: false,
  24. swipedL: false,
  25. tapTypeL: '',
  26. tapTypeR: '',
  27. });
  28. this.setData({ inertiaWidth: elasticity ? 20 : 0 });
  29. },
  30. } });
  31. }
  32. return __assign({}, original);
  33. }
  34. export function transformProperties(props) {
  35. var properties = {};
  36. Object.keys(props).forEach(function (key) {
  37. properties[key] = {
  38. type: null,
  39. value: props[key],
  40. };
  41. });
  42. return properties;
  43. }