driver.js
driver.js copied to clipboard
[Feature Request] Expose step index in DOM
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.
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.