Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tabs-touch.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Tabs touch
  3. *
  4. * @mixin
  5. */
  6. /* @vue/component */
  7. export default {
  8. methods: {
  9. newOffset: function newOffset(direction) {
  10. var clientWidth = this.$refs.wrapper.clientWidth;
  11. if (direction === 'prev') {
  12. return Math.max(this.scrollOffset - clientWidth, 0);
  13. } else {
  14. return Math.min(this.scrollOffset + clientWidth, this.$refs.container.clientWidth - clientWidth);
  15. }
  16. },
  17. onTouchStart: function onTouchStart(e) {
  18. this.startX = this.scrollOffset + e.touchstartX;
  19. this.$refs.container.style.transition = 'none';
  20. this.$refs.container.style.willChange = 'transform';
  21. },
  22. onTouchMove: function onTouchMove(e) {
  23. this.scrollOffset = this.startX - e.touchmoveX;
  24. },
  25. onTouchEnd: function onTouchEnd() {
  26. var container = this.$refs.container;
  27. var wrapper = this.$refs.wrapper;
  28. var maxScrollOffset = container.clientWidth - wrapper.clientWidth;
  29. container.style.transition = null;
  30. container.style.willChange = null;
  31. /* istanbul ignore else */
  32. if (this.scrollOffset < 0 || !this.isOverflowing) {
  33. this.scrollOffset = 0;
  34. } else if (this.scrollOffset >= maxScrollOffset) {
  35. this.scrollOffset = maxScrollOffset;
  36. }
  37. }
  38. }
  39. };
  40. //# sourceMappingURL=tabs-touch.js.map