fatihsolhan / v-onboarding

v-onboarding is a super-slim, fully-typed onboarding component for Vue 3
https://v-onboarding.fatihsolhan.com/
MIT License
170 stars 22 forks source link

Add indicator for previous click #77

Closed Farnsi closed 8 months ago

Farnsi commented 1 year ago

on.beforeStep should get an argument, that indicates if previous button was clicked.

rozsazoltan commented 1 year ago

Yes, I also thought about that. Although it's not needed often, it can be advantageous to associate an action with whether we moved forward or backward on certain occasions.

I was thinking something similar to this here:

https://github.com/fatihsolhan/v-onboarding/issues/74#issuecomment-1585535236

I would pass an argument to the beforeStep and afterStep functions indicating whether the current step is a "backward" or "forward" step in the sequence. Using this, you can reference it within the function.

Now

const step = {
  on: {
    beforeStep: () => { /* ... */ },
    afterStep: () => { /* ... */ }
  }
}

Feature

const step = {
  on: {
    beforeStep: (type?: "forward" | "backward") => { /* ... */ },
    afterStep: (type?: "forward" | "backward") => { /* ... */ }
  }
}

The original argument-less function definition, () => { ... }, will continue to work. However, if you need to differentiate the logic based on whether it's a forward or backward step, you have the option to do so.

fatihsolhan commented 8 months ago

Hi, this is possible after version 2.6.0 thanks to @rozsazoltan https://github.com/fatihsolhan/v-onboarding/pull/83 Docs: https://v-onboarding-docs.fatihsolhan.com/props/hooks