index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. define([
  2. 'text!./index.html',
  3. 'css!./index.css'
  4. ], function(html) {
  5. return {
  6. props: ['rebateMoney'],
  7. data: function () {
  8. return {
  9. top: 0,
  10. ticking: false,
  11. innerHeight: window.innerHeight,
  12. maxHeight: 0
  13. };
  14. },
  15. mounted: function () {
  16. this.$nextTick(function () {
  17. this.top = this.maxHeight = this.innerHeight - this.$refs.rebate.offsetHeight - this.$refs.close.offsetHeight + this.$refs.close.offsetTop;
  18. });
  19. },
  20. methods: {
  21. rebateAction: function (value) {
  22. this.$emit('rebate-action', value);
  23. },
  24. touchMove: function (event) {
  25. if (!this.ticking) {
  26. window.requestAnimationFrame(function () {
  27. this.ticking = false;
  28. if (event.changedTouches[0].clientY < this.$refs.close.offsetHeight - this.$refs.close.offsetTop) {
  29. this.top = this.$refs.close.offsetHeight - this.$refs.close.offsetTop;
  30. } else if (event.changedTouches[0].clientY > this.maxHeight) {
  31. this.top = this.maxHeight;
  32. } else {
  33. this.top = event.changedTouches[0].clientY;
  34. }
  35. }.bind(this));
  36. }
  37. this.ticking = true;
  38. }
  39. },
  40. template: html
  41. };
  42. });