Skip to content

Commit

Permalink
feat: add hide-loading option
Browse files Browse the repository at this point in the history
closes #315
  • Loading branch information
RomanHotsiy committed Aug 2, 2017
1 parent 3009d18 commit 2ebca4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica
* `required-props-first` - show required properties first ordered in the same order as in `required` array.
* `no-auto-auth` - do not inject Authentication section automatically
* `path-in-middle-panel` - show path link and HTTP verb in the middle panel instead of the right one
* `hide-loading` - do not show loading animation. Useful for small docs

## Advanced usage
Instead of adding `spec-url` attribute to the `<redoc>` element you can initialize ReDoc via globally exposed `Redoc` object:
Expand Down
6 changes: 6 additions & 0 deletions lib/components/Redoc/redoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export class Redoc extends BaseComponent implements OnInit {
}

hideLoadingAnimation() {
if (this.options.hideLoading) {
return
}
requestAnimationFrame(() => {
this.specLoadingRemove = true;
setTimeout(() => {
Expand All @@ -99,6 +102,9 @@ export class Redoc extends BaseComponent implements OnInit {
}

showLoadingAnimation() {
if (this.options.hideLoading) {
return
}
this.specLoading = true;
this.specLoadingRemove = false;
}
Expand Down
5 changes: 4 additions & 1 deletion lib/services/options.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const OPTION_NAMES = new Set([
'requiredPropsFirst',
'noAutoAuth',
'pathInMiddlePanel',
'untrustedSpec'
'untrustedSpec',
'hideLoading'
]);

export interface Options {
Expand All @@ -35,6 +36,7 @@ export interface Options {
noAutoAuth?: boolean;
pathInMiddlePanel?: boolean;
untrustedSpec?: boolean;
hideLoading?: boolean;
spec?: any;
}

Expand Down Expand Up @@ -104,6 +106,7 @@ export class OptionsService {
if (isString(this._options.noAutoAuth)) this._options.noAutoAuth = true;
if (isString(this._options.pathInMiddlePanel)) this._options.pathInMiddlePanel = true;
if (isString(this._options.untrustedSpec)) this._options.untrustedSpec = true;
if (isString(this._options.hideLoading)) this._options.hideLoading = true;
if (isString(this._options.expandResponses)) {
let str = this._options.expandResponses as string;
if (str === 'all') return;
Expand Down

0 comments on commit 2ebca4b

Please sign in to comment.