wechat.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. }, options: {
  11. multipleSlots: true,
  12. styleIsolation: 'shared',
  13. }, observers: {
  14. 'damping, swiped': function () {
  15. this.setData({
  16. swipeX: 0,
  17. swipedR: false,
  18. swipedL: false,
  19. tapTypeL: '',
  20. tapTypeR: '',
  21. });
  22. },
  23. 'elasticity': function (elasticity) {
  24. this.setData({
  25. swipeX: 0,
  26. swipedR: false,
  27. swipedL: false,
  28. tapTypeL: '',
  29. tapTypeR: '',
  30. });
  31. this.setData({ inertiaWidth: elasticity ? 20 : 0 });
  32. },
  33. } });
  34. }
  35. return __assign({}, original);
  36. }
  37. export function transformProperties(props) {
  38. var properties = {};
  39. Object.keys(props).forEach(function (key) {
  40. properties[key] = {
  41. type: null,
  42. value: props[key],
  43. };
  44. });
  45. return properties;
  46. }