Zulko / eagle.js

A hackable slideshow framework built with Vue.js
https://zulko.github.io/eaglejs-demo/
ISC License
4.08k stars 223 forks source link

Slide number #96

Closed christian-nils closed 4 years ago

christian-nils commented 4 years ago

Hi!

I was wondering, is it possible to access the slide number in the slide component? According to https://github.com/Zulko/eagle.js/issues/29, you can use the variable currentSlideIndexin the Slideshow component. However, my slides have different background and it may be easier to access the variable within the slides.

What do you think would be the easiest way? I am modifying the Slide component right now to get the variable. But maybe there is a better way.

Thanks!

/CN

Edit: I have added two slots to the original slide template, I have now "header", "content", "footer" (instead of only "content"). If someone is interested -> https://github.com/christian-nils/eagle.js Then it is just sufficient to create your header or footer in your Slideshow component. For instance, below I have implemented my footer, it includes three parts (left, center, right).

<template lang="pug">
  .eg-theme-agrume
    .eg-slideshow
      slide(...)
        template
          router-view(v-bind:step="step")
        template(v-if="((slide.slideNumber == undefined )? true : slide.slideNumber)" #footer).eg-slide-footer.eg-footer
          .left-part
            ChalmersLOGO
          .center-part
          .right-part
            span {{ currentSlideIndex }}
</template>
yaodingyd commented 4 years ago

If we have slide number in slide, it will just be a pass-down property from slideshow. It will be more or less the same to access this.$parent. currentSlideIndex.

I would say given the complexity of your slide component, you might want to use mixin for you slide, in this way you can store the slide number as data in your slide.

christian-nils commented 4 years ago

Alright! Thanks for the tips @yaodingyd! Have a great day