StoryTimelineComponent.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div>
  3. <div v-if="stories.length != 0">
  4. <div id="storyContainer" :class="[list == true ? 'mt-1 mr-3 mb-0 ml-1':'mx-3 mt-3 mb-0 pb-0']"></div>
  5. </div>
  6. </div>
  7. </template>
  8. <style type="text/css" scoped>
  9. #storyContainer > .story {
  10. margin-right: 3rem;
  11. }
  12. </style>
  13. <script type="text/javascript">
  14. import 'zuck.js/dist/zuck.css';
  15. import 'zuck.js/dist/skins/snapgram.css';
  16. let Zuck = require('zuck.js');
  17. export default {
  18. props: ['list'],
  19. data() {
  20. return {
  21. stories: {},
  22. }
  23. },
  24. mounted() {
  25. this.fetchStories();
  26. },
  27. methods: {
  28. fetchStories() {
  29. axios.get('/api/stories/v0/recent')
  30. .then(res => {
  31. let data = res.data;
  32. let stories = new Zuck('storyContainer', {
  33. list: this.list == true ? true : false,
  34. stories: data,
  35. localStorage: true,
  36. callbacks: {
  37. onOpen (storyId, callback) {
  38. document.body.style.overflow = "hidden";
  39. callback()
  40. },
  41. onEnd (storyId, callback) {
  42. axios.post('/i/stories/viewed', {
  43. id: storyId
  44. });
  45. callback();
  46. },
  47. onClose (storyId, callback) {
  48. document.body.style.overflow = "auto";
  49. callback();
  50. },
  51. }
  52. });
  53. data.forEach(d => {
  54. let url = '/api/stories/v0/fetch/' + d.pid;
  55. axios.get(url)
  56. .then(res => {
  57. res.data.forEach(item => {
  58. let img = new Image();
  59. img.src = item.src;
  60. stories.addItem(d.id, item);
  61. });
  62. });
  63. });
  64. });
  65. }
  66. }
  67. }
  68. </script>
  69. <style type="text/css">
  70. #storyContainer .story {
  71. margin-right: 2rem;
  72. width: 100%;
  73. max-width: 60px;
  74. }
  75. .stories.carousel .story > .item-link > .item-preview {
  76. height: 60px;
  77. }
  78. #zuck-modal.with-effects {
  79. width: 100%;
  80. }
  81. .stories.carousel .story > .item-link > .info .name {
  82. font-weight: 500;
  83. font-size: 11px;
  84. }
  85. .stories.carousel .story > .item-link > .info {
  86. }
  87. </style>