index.js 707 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { use } from '../utils';
  2. const [sfc, bem] = use('swipe-item');
  3. export default sfc({
  4. data() {
  5. return {
  6. offset: 0
  7. };
  8. },
  9. beforeCreate() {
  10. this.$parent.swipes.push(this);
  11. },
  12. destroyed() {
  13. this.$parent.swipes.splice(this.$parent.swipes.indexOf(this), 1);
  14. },
  15. render(h) {
  16. const { vertical, computedWidth, computedHeight } = this.$parent;
  17. const style = {
  18. width: computedWidth + 'px',
  19. height: vertical ? computedHeight + 'px' : '100%',
  20. transform: `translate${vertical ? 'Y' : 'X'}(${this.offset}px)`
  21. };
  22. return (
  23. <div class={bem()} style={style} {...{ on: this.$listeners }}>
  24. {this.slots()}
  25. </div>
  26. );
  27. }
  28. });