index.js 1001 B

123456789101112131415161718192021222324252627282930313233343536
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { use } from '../utils';
  3. var _use = use('swipe-item'),
  4. sfc = _use[0],
  5. bem = _use[1];
  6. export default sfc({
  7. data: function data() {
  8. return {
  9. offset: 0
  10. };
  11. },
  12. beforeCreate: function beforeCreate() {
  13. this.$parent.swipes.push(this);
  14. },
  15. destroyed: function destroyed() {
  16. this.$parent.swipes.splice(this.$parent.swipes.indexOf(this), 1);
  17. },
  18. render: function render(h) {
  19. var _this$$parent = this.$parent,
  20. vertical = _this$$parent.vertical,
  21. computedWidth = _this$$parent.computedWidth,
  22. computedHeight = _this$$parent.computedHeight;
  23. var style = {
  24. width: computedWidth + 'px',
  25. height: vertical ? computedHeight + 'px' : '100%',
  26. transform: "translate" + (vertical ? 'Y' : 'X') + "(" + this.offset + "px)"
  27. };
  28. return h("div", {
  29. "class": bem(),
  30. "style": style,
  31. "on": _extends({}, this.$listeners)
  32. }, [this.slots()]);
  33. }
  34. });