@andresciceri/ngx-intro
Version:
Angular wrapper for intro.js
58 lines (54 loc) • 2.1 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable } from '@angular/core';
import * as introJs from 'intro.js';
class IntrojsService {
intro;
renderer;
constructor(rendererFactory) {
this.renderer = rendererFactory.createRenderer(null, null);
this.intro = introJs.default();
}
setOptions(options) {
this.intro.setOptions(options);
}
startTour(steps, options) {
// Updated to Partial<Options>
this.intro.setOptions({ steps, ...options });
this.intro.start();
}
exitTour(force) {
this.intro.exit(force);
}
onComplete(callback) {
this.intro.oncomplete(callback);
}
onExit(callback) {
this.intro.onexit(callback);
}
applyTheme(themeUrl) {
const linkElement = document.getElementById('introjs-theme');
if (linkElement) {
linkElement.href = themeUrl;
}
else {
const newLinkElement = this.renderer.createElement('link');
this.renderer.setAttribute(newLinkElement, 'rel', 'stylesheet');
this.renderer.setAttribute(newLinkElement, 'id', 'introjs-theme');
this.renderer.setAttribute(newLinkElement, 'href', themeUrl);
document.head.appendChild(newLinkElement);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: IntrojsService, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: IntrojsService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: IntrojsService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}], ctorParameters: () => [{ type: i0.RendererFactory2 }] });
/**
* Generated bundle index. Do not edit.
*/
export { IntrojsService };
//# sourceMappingURL=andresciceri-ngx-intro.mjs.map