123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <div class="container">
- <div v-if="loading" class="row">
- <div class="col-12 mt-5 pt-5">
- <div class="text-center">
- <div class="spinner-border" role="status">
- <span class="sr-only">Loading...</span>
- </div>
- </div>
- </div>
- </div>
- <div v-if="stories.length != 0">
- <div id="storyContainer" class="d-none m-3"></div>
- </div>
- </div>
- </template>
- <script type="text/javascript">
- import 'zuck.js/dist/zuck.css';
- import 'zuck.js/dist/skins/snapgram.css';
- window.Zuck = require('zuck.js');
- export default {
- props: ['pid'],
- data() {
- return {
- loading: true,
- stories: {},
- }
- },
- beforeMount() {
- this.fetchStories();
- },
- methods: {
- fetchStories() {
- axios.get('/api/stories/v1/profile/' + this.pid)
- .then(res => {
- let data = res.data;
- if(data.length == 0) {
- window.location.href = '/';
- return;
- }
- window._storyData = data;
- window.stories = new Zuck('storyContainer', {
- stories: data,
- localStorage: false,
- callbacks: {
- onOpen (storyId, callback) {
- document.body.style.overflow = "hidden";
- callback()
- },
- onEnd (storyId, callback) {
- axios.post('/i/stories/viewed', {
- id: storyId
- });
- callback();
- },
- onClose (storyId, callback) {
- document.body.style.overflow = "auto";
- callback();
- window.location.href = '/';
- },
- }
- });
- this.loading = false;
- // todo: refactor this mess
- document.querySelectorAll('#storyContainer .story')[0].click()
- })
- .catch(err => {
- window.location.href = '/';
- return;
- });
- }
- }
- }
- </script>
- <style type="text/css">
- #storyContainer .story {
- margin-right: 2rem;
- width: 100%;
- max-width: 64px;
- }
- .stories.carousel .story > .item-link > .item-preview {
- height: 64px;
- }
- #zuck-modal.with-effects {
- width: 100%;
- }
- .stories.carousel .story > .item-link > .info .name {
- font-weight: 600;
- font-size: 12px;
- }
- .stories.carousel .story > .item-link > .info {
- }
- </style>
|