mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-12 07:50:34 +03:00
Add simple animations
This commit is contained in:
parent
a482c0b29e
commit
791355c60a
|
@ -10,7 +10,7 @@
|
||||||
<div *ngFor="let cat of data.menu; let idx = index" class="menu-cat">
|
<div *ngFor="let cat of data.menu; let idx = index" class="menu-cat">
|
||||||
|
|
||||||
<label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [ngClass]="{active: cat.active}"> {{cat.name}}</label>
|
<label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [ngClass]="{active: cat.active}"> {{cat.name}}</label>
|
||||||
<ul class="menu-subitems" [ngClass]="{active: cat.active}">
|
<ul class="menu-subitems" @itemAnimation="cat.active ? 'expanded' : 'collapsed'">
|
||||||
<li *ngFor="let method of cat.methods; let methIdx = index"
|
<li *ngFor="let method of cat.methods; let methIdx = index"
|
||||||
[ngClass]="{active: method.active}"
|
[ngClass]="{active: method.active}"
|
||||||
(click)="activateAndScroll(idx, methIdx)">
|
(click)="activateAndScroll(idx, methIdx)">
|
||||||
|
|
|
@ -38,7 +38,6 @@ $mobile-menu-compact-breakpoint: 550px;
|
||||||
font-weight: $light;
|
font-weight: $light;
|
||||||
color: rgba($text-color, .9);
|
color: rgba($text-color, .9);
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 0;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import { ElementRef, ChangeDetectorRef } from '@angular/core';
|
import { ElementRef, ChangeDetectorRef } from '@angular/core';
|
||||||
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
import { global } from '@angular/core/src/facade/lang';
|
import { global } from '@angular/core/src/facade/lang';
|
||||||
|
import { trigger, state, animate, transition, style } from '@angular/core';
|
||||||
import { RedocComponent, BaseComponent, SchemaManager } from '../base';
|
import { RedocComponent, BaseComponent, SchemaManager } from '../base';
|
||||||
import { ScrollService, Hash, MenuService, OptionsService } from '../../services/index';
|
import { ScrollService, Hash, MenuService, OptionsService } from '../../services/index';
|
||||||
|
|
||||||
|
@ -13,7 +13,18 @@ import { ScrollService, Hash, MenuService, OptionsService } from '../../services
|
||||||
providers: [ScrollService, MenuService, Hash],
|
providers: [ScrollService, MenuService, Hash],
|
||||||
styleUrls: ['./side-menu.css'],
|
styleUrls: ['./side-menu.css'],
|
||||||
detect: true,
|
detect: true,
|
||||||
onPushOnly: false
|
onPushOnly: false,
|
||||||
|
animations: [
|
||||||
|
trigger('itemAnimation', [
|
||||||
|
state('collapsed, void',
|
||||||
|
style({ height: '0px' })),
|
||||||
|
state('expanded',
|
||||||
|
style({ height: '*' })),
|
||||||
|
transition('collapsed <=> expanded', [
|
||||||
|
animate(200)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class SideMenu extends BaseComponent {
|
export class SideMenu extends BaseComponent {
|
||||||
$element: any;
|
$element: any;
|
||||||
|
|
|
@ -79,6 +79,7 @@ export function RedocComponent(options) {
|
||||||
changeDetection: options.detect ?
|
changeDetection: options.detect ?
|
||||||
(options.onPushOnly ? ChangeDetectionStrategy.OnPush : ChangeDetectionStrategy.Default) :
|
(options.onPushOnly ? ChangeDetectionStrategy.OnPush : ChangeDetectionStrategy.Default) :
|
||||||
ChangeDetectionStrategy.Detached,
|
ChangeDetectionStrategy.Detached,
|
||||||
|
animations: options.animations,
|
||||||
templateUrl: options.templateUrl,
|
templateUrl: options.templateUrl,
|
||||||
template: options.template,
|
template: options.template,
|
||||||
styles: options.styles,
|
styles: options.styles,
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
<span class="zippy-indicator">{{ visible ? '▾' : '▸' }}</span>
|
<span class="zippy-indicator">{{ visible ? '▾' : '▸' }}</span>
|
||||||
{{title}}
|
{{title}}
|
||||||
</div>
|
</div>
|
||||||
<div class="zippy-content" [ngClass]="{'zippy-hidden': !visible}">
|
<div class="zippy-content" @openClose="visible ? 'expanded' : 'collapsed'">
|
||||||
|
<div class="zippy-content-wrap">
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -47,6 +47,10 @@ span.zippy-indicator {
|
||||||
}
|
}
|
||||||
|
|
||||||
.zippy-content {
|
.zippy-content {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zippy-content-wrap {
|
||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,25 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Component, EventEmitter, Output, Input } from '@angular/core';
|
import { Component, EventEmitter, Output, Input,
|
||||||
|
trigger, state, animate, transition, style } from '@angular/core';
|
||||||
import { CORE_DIRECTIVES } from '@angular/common';
|
import { CORE_DIRECTIVES } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'zippy',
|
selector: 'zippy',
|
||||||
templateUrl: './zippy.html',
|
templateUrl: './zippy.html',
|
||||||
styleUrls: ['./zippy.css'],
|
styleUrls: ['./zippy.css'],
|
||||||
directives: [CORE_DIRECTIVES]
|
directives: [CORE_DIRECTIVES],
|
||||||
|
animations: [
|
||||||
|
trigger('openClose', [
|
||||||
|
state('collapsed, void',
|
||||||
|
style({ height: '0px' })),
|
||||||
|
state('expanded',
|
||||||
|
style({ height: '*' })),
|
||||||
|
transition('collapsed <=> expanded', [
|
||||||
|
animate(200)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class Zippy {
|
export class Zippy {
|
||||||
@Input() type = 'general';
|
@Input() type = 'general';
|
||||||
|
@ -16,10 +28,13 @@ export class Zippy {
|
||||||
@Input() title;
|
@Input() title;
|
||||||
@Output() open = new EventEmitter();
|
@Output() open = new EventEmitter();
|
||||||
@Output() close = new EventEmitter();
|
@Output() close = new EventEmitter();
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
this.visible = !this.visible;
|
this.visible = !this.visible;
|
||||||
if (this.empty) return;
|
if (this.empty) return;
|
||||||
(this.visible) ? this.open.next({}) : this.close.next({});
|
if (this.visible) {
|
||||||
|
this.open.next({});
|
||||||
|
} else {
|
||||||
|
this.close.next({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user