Skip to content

Commit

Permalink
move disableZenscroll option
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Feb 8, 2024
1 parent 953fffb commit 2bb4211
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
5 changes: 1 addition & 4 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
RedocTryItOut.init(
"./openapi.json",
{
title: "Pet Store",
swaggerOptions: {
disableZenscroll: true
}
title: "Pet Store"
},
document.getElementById("redoc_container"),
);
Expand Down
4 changes: 2 additions & 2 deletions dist/try-it-out.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/config/redoc-try-it-out-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class RedocTryItOutConfig implements RedocTryItOutOptions {
public readonly tryItBoxContainerId: string = "try-out-wrapper";
public readonly redocVersion: string = DEFAULT_REDOC_VERSION;
public readonly selectedOperationClass: string = "try";
public readonly disableZenscroll: boolean = true;

public readonly dependenciesVersions: DependenciesVersions = {
jquery: DEFAULT_JQUERY_VERSION,
Expand Down
1 change: 0 additions & 1 deletion src/config/swagger-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class SwaggerConfig implements SwaggerOptions {
public readonly hideClass: string = "hide";
public readonly showClass: string = "show";
public readonly selectedOperationContainerClass: string = "opened-shadow";
public readonly disableZenscroll: boolean = true;

public readonly version: string = "3.48.0";

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/redoc-try-it-out-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,5 @@ export interface RedocTryItOutOptions extends RedocOptions {
tryBtn?: TryBtnOptions;
swaggerOptions?: SwaggerOptions;
stylerMatcher?: StyleMatcherOptions;
disableZenscroll?: boolean;
}
4 changes: 0 additions & 4 deletions src/interfaces/swagger-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ export interface SwaggerOptions {
selectedOperationContainerClass?: string;
wrapperSelector?: string;
onComplete?: CallbackFunction;
// This is not actually a Swagger UI option, but it's used in the code to disable zenscroll
// and its on by default if swaggerOptions is passed in to the RedocTryItOutConfig
// Extra options like this that are passed into Swagger UI will be ignored anyway
disableZenscroll?: boolean;
}
8 changes: 5 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ export class RedocTryItOut {
cfg: RedocTryItOutOptions,
element?: HTMLElement,
): Promise<void> {
// This parses and sets the config on the static cfg property on the RedocWrapper class
RedocTryItOut.config(docUrl, cfg, element);

if (RedocWrapper.cfg.disableZenscroll) {
(window as any).noZensmooth = true;
}

if (RedocWrapper.cfg.tryItOutEnabled) {
if (cfg.swaggerOptions?.disableZenscroll) {
(window as any).noZensmooth = true;
}
await RedocTryItOut.loadAll();
AuthBtn.init();
TryBtn.init();
Expand Down

0 comments on commit 2bb4211

Please sign in to comment.