0.9.8 • Published 8 months ago

vue-insta-stories v0.9.8

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Simple usage

<template>
  <Stories :stories="items" />
</template>

<script>
import { Stories } from "vue-insta-stories";
export default {
  components: { Stories },
  data: () => ({
    items: [
      "https://picsum.photos/350/200/",
      "https://picsum.photos/400/201/",
      {
        url: "https://file-examples-com.github.io/5mb.mp4",
        type: "video",
      },
    ]
  })
};
</script>

Props

PropertyTypeDefaultDescription
storiesArray<String|Object>requiredAn array of image urls or array of story objects (more info below)
intervalNumber2000Story duration in milliseconds
isPausedBooleanfalseToggle the playing state
loopBooleanfalseLoop through stories
currentIndexNumber0Set the current story index
Events
storyStartFunction(index)-Callback when a story starts
storyEndFunction(index)-Callback when a story ends
allStoriesEndFunction()-Callback when all stories have ended (not emitted if loop=true)
seeMoreFunction(story)-Callback when user have pressed See more
prevFunction()-Callback when user press prev
nextFunction()-Callback when user press next
update:currentIndexFunction(index)-
update:isPausedFunction(paused)-

Story Object

PropertyDescription
urlThe url of the resource, image or video.
typeOptional. Type of the story. 'image' \| 'video'
durationOptional. Duration for which a story should persist.
templateOptional. Renders story in a different template see more below.
seeMoreOptional. Enable see more on story (true \| { label: 'See more!' }

Style

/** full screen on mobile & fixed size on desktop **/
.ig-stories {
  position: absolute;
  height: 100vh;
  height: -webkit-fill-available;
  width: 100vw;
  top: 0;
}

@media (min-width: 768px) {
  .ig-stories {
    position: relative;
    height: 730px;
    width: 420px;
  }
}

if you are using tailwind you can write

<Stories class="absolute top-0 h-100vh w-100vw md:(h-730px w-420px relative)" />

With header

<template>
  <Stories :stories="items">
    <template #header="{story}">
      <story-header :story="story" />
    </template>
  </Stories>
</template>

<script>
import { Stories } from "vue-insta-stories";
export default {
  components: { Stories },
  data: () => ({
    items: [ "https://picsum.photos/350/200/"]
  })
};
</script>

With custom slot

<template>
  <Stories :stories="items">
    <template #pool="{story}">
        <pool-story :story="story" class="flex-grow"></pool-story>
    </template>
  </Stories>
</template>

<script>
import { Stories } from "vue-insta-stories";
export default {
  components: { Stories },
  data: () => ({
    items: [{ poolId: 23, template: "pool" }]
  })
};
</script>
0.9.8

8 months ago

0.9.7

8 months ago

0.9.4

11 months ago

0.9.6

8 months ago

0.9.3

3 years ago

0.9.2

3 years ago

0.1.1

3 years ago

0.9.0

3 years ago

0.9.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

3.0.0

3 years ago