Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement additional slots #34

Merged
merged 2 commits into from
Nov 12, 2020
Merged

Conversation

Draccano
Copy link
Contributor

@Draccano Draccano commented Nov 11, 2020

For my personal purposes I needed to implement different item at the beginning/ending of the item list. The code is tested. User can add additional v-slot:start and v-slot:end to the existing v-slot:default.

Example of use:

<vue-horizontal-list :items="items" options="{responsive: [{end: 576, size: 1}, {start: 576, end: 768, size: 2},{size: 3}]}">
      <template v-slot:start>
          <div class="start-item" style="background:red;">
              This is start item
          </div>
      </template>
      <template v-slot:default="{item}">
          <div class="item">
            <h5>{{item.title}}</h5>
            <p>{{item.content}}</p>
          </div>
       </template>
       <template v-slot:end>
          <div class="end-item" style="background: green;">
             This is end item
          </div>
      </template>
</vue-horizontal-list>

Example shown in the video https://streamable.com/c8fzu3

Comment on lines +125 to +127
this.totalCount = this.items.length;
this.totalCount += this.$slots['start'] ? 1 : 0;
this.totalCount += this.$slots['end'] ? 1 : 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be computed so that it will be updated when parent changes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, thanks for this commit, I will resolve the issue mentioned on my dev branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not problem, however I just lost commits credit reference in the project :(

@fuxingloh fuxingloh changed the base branch from master to fix/dev November 12, 2020 15:45
@fuxingloh fuxingloh merged commit 183b62b into fuxingloh:fix/dev Nov 12, 2020
@fuxingloh fuxingloh added this to the v1.2.0 milestone Nov 12, 2020
fuxingloh pushed a commit that referenced this pull request Nov 12, 2020
* Implement additional slots
* Upgrade readme
fuxingloh added a commit that referenced this pull request Nov 12, 2020
* Implement additional slots (#34)

* Implement additional slots
* Upgrade readme

* You can now start horizontal slides from nth item instead of always starting from 0 (#39)

Co-authored-by: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com>

* Implement additional slots (#34)

* Implement additional slots
* Upgrade readme

* You can now start horizontal slides from nth item instead of always starting from 0 (#39)

Co-authored-by: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com>

* Prettier formatted

* Unified start position into options as {position: {start: 0} }
Converted start and end provided by slots into computed _items

Co-authored-by: Adam Richter <dracossos@gmail.com>
Co-authored-by: Vikas Kedia <kedia.vikas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants