driver.js icon indicating copy to clipboard operation
driver.js copied to clipboard

[Feature Request] Expose step index in DOM

Open lonix1 opened this issue 1 year ago • 1 comments

The widget's current step is exposed via JS callbacks; those can be used to apply custom styling.

However it would be simpler and neater to control that via css directly. For example:

<div class="driver-popover" data-step-index="3" data-step-first="true" data-step-last="false">
  ...
</div>

Notice the [data-step-index], [data-step-first] and [data-step-last] attributes. I could easily target those in css.

lonix1 avatar May 02 '24 14:05 lonix1

A workaround for now:

const driver = window.driver.js.driver;
const driverObj = driver({
  onPopoverRender: function(popover, options) {
    popover.wrapper.setAttribute('data-step-index', driverObj.getActiveIndex());
    popover.wrapper.setAttribute('data-step-first', driverObj.isFirstStep());
    popover.wrapper.setAttribute('data-step-last', driverObj.isLastStep());
  },
});

But this is not ideal as it's messy and runs repeatedly. Best to be in the library itself.

lonix1 avatar May 04 '24 12:05 lonix1