notiflix / Notiflix

Notiflix is a pure JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.
https://notiflix.github.io
MIT License
647 stars 55 forks source link

[FEAT] - Feature Request: Redirect Option After Notify Disappears in Notiflix #87

Closed HakanKorkz closed 2 months ago

HakanKorkz commented 2 months ago

Feature Request:

Is your feature request related to a problem? Please describe. I've integrated the Notiflix package into my project for feedback notifications. However, I've noticed a missing feature. When I use the Notify function, there is no option to redirect to a specific page once the notification disappears after the duration ends.

Describe the solution you'd like I would like to have an option to specify a redirection to a certain page once the Notify notification disappears after the set duration.

Describe alternatives you've considered As an alternative, I am considering manually triggering a redirection after the Notify function completes, but a built-in option would be more efficient.

Additional context This feature would enhance the usability of the Notiflix Notify function by allowing seamless navigation for users after receiving a notification.

furcan commented 2 months ago

Hello,

You can follow something like the below; such features are not the intention of this library 🙏

const showANotifyAndHandleMyCustomExpectation = () => {
  const timeoutForNotify = 3000;
  const timeoutAlsoForCSSAnimationDuration = 400;

  Notiflix.Notify.success(
    'Lorem ipsum dolor sit amet',
    {
      timeout: timeoutForNotify,
      cssAnimationDuration: timeoutAlsoForCSSAnimationDuration,
    },
  );

  const myCustomExpectation = window.setTimeout(() => {

    // do stuff...

    window.clearTimeout(myCustomExpectation)
  }, timeoutForNotify + timeoutAlsoForCSSAnimationDuration);
};

// call for show a notify and do stuff...
showANotifyAndHandleMyCustomExpectation();

Notify Options => https://github.com/notiflix/Notiflix#notiflix-notify-module-default-options

Thanks, Furkan

HakanKorkz commented 2 months ago

Hello,

You can follow something like the below; such features are not the intention of this library 🙏

const showANotifyAndHandleMyCustomExpectation = () => {
  const timeoutForNotify = 3000;
  const timeoutAlsoForCSSAnimationDuration = 400;

  Notiflix.Notify.success(
    'Lorem ipsum dolor sit amet',
    {
      timeout: timeoutForNotify,
      cssAnimationDuration: timeoutAlsoForCSSAnimationDuration,
    },
  );

  const myCustomExpectation = window.setTimeout(() => {

    // do stuff...

    window.clearTimeout(myCustomExpectation)
  }, timeoutForNotify + timeoutAlsoForCSSAnimationDuration);
};

// call for show a notify and do stuff...
showANotifyAndHandleMyCustomExpectation();

Notify Options => https://github.com/notiflix/Notiflix#notiflix-notify-module-default-options

Thanks, Furkan

Thank you for the return.

Yes, you are right, what I actually want to explain is that if a calback function is executed when the timeout expires, for example timeOutFunc: { console.log(“ notification removed”) } style, for example, I think anyone can apply the scenario they want in fancy brackets.

furcan commented 2 months ago

I will consider this use case/feature for the next major version (not soon) that I am planning to rewrite the library. So until than, the snippet I shared would be OK.

Thank you.

HakanKorkz commented 2 months ago

Thank you for the return. I will be looking forward to the new update