question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: emit event when currentPage changes

See original GitHub issue

related: #25

I want to handle navigation from outside the Carousel. I am using Vuex, so it would be handy to have an event emitted when the currentPage changes. I could do it, add a watcher on currentPage that emits an event, and create a pull request, if you want.

I tried this, but it does not work, would be nice though:

watch: {
  '$refs.carousel.currentPage' () {
    if (this.currentPage !== this.$refs.carousel.currentPage) {
      store.dispatch('carousel/currentPageChanged', this.$refs.carousel.currentPage)
    }
  }
}

The rest should work like this (did not test):

computed: {
  ...mapGetters('carousel', [
    'currentPage'
  ])
},
watch: {
  currentPage () {
    if (this.currentPage !== this.$refs.carousel.currentPage) {
      this.$refs.carousel.goToPage(this.currentPage)
    }
  }
}

Thank you!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mandawancommented, Oct 4, 2017

Hello,

I didn’t find out how to use this “Event on page changed” feature properly. Through Vuex $store then ? . Am I wrong or is this not documented yet ? Can you please provide a very quick example, for example an implementation of a listener to that event ? That is just the little last thing I need.

Thanks.

1reaction
toddlawtoncommented, Mar 3, 2017

I merged in your change and released it under 0.6.4. Your contribution is appreciated! 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Paginator] Does not emit event when changed ...
Assigning to .pageIndex does not emit a page event. There is no method to jump to a specified page and ensure that an...
Read more >
Detect changes on the url - javascript
There is no "clean", event-based way to detect such URL changes from a ... emit a DOM event that can be listened to...
Read more >
Page Lifecycle API - Chrome Developers
The Page Lifecycle API brings app lifecycle features common on mobile ... Note: a focus event does not necessarily signal a state change....
Read more >
Window: popstate event - Web APIs | MDN
The popstate event of the Window interface is fired when the active history entry changes while the user navigates the session history.
Read more >
Feature requests | Optimizely Developer Community
Request new features in Optimizely products; everything from user interface to API changes. Note: This forum is closed for submissions, please visit Optimizely ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found