fix: emit events for hovered key

This commit is contained in:
Oscar Lorentzon 2018-11-07 12:32:40 +00:00
parent 8795943193
commit ec7e11d23e
2 changed files with 43 additions and 7 deletions

View File

@ -21,15 +21,28 @@ export class DirectionComponent extends Component<IDirectionConfiguration> {
/** @inheritdoc */
public static componentName: string = "direction";
/**
* Event fired when the hovered key changes.
*
* @description Emits the key of the node for the direction
* arrow that is being hovered. When the mouse leaves a
* direction arrow null is emitted.
*
* @event DirectionComponent#hoveredkeychanged
* @type {string} The hovered key, null if no key is hovered.
*/
public static hoveredkeychanged: string = "hoveredkeychanged";
private _renderer: DirectionDOMRenderer;
private _hoveredKeySubject$: Subject<string>;
private _hoveredKey$: Observable<string>;
private _configurationSubscription: Subscription;
private _emitHoveredKeySubscription: Subscription;
private _hoveredKeySubscription: Subscription;
private _nodeSubscription: Subscription;
private _renderCameraSubscription: Subscription;
private _hoveredKeySubscription: Subscription;
constructor(name: string, container: Container, navigator: Navigator, directionDOMRenderer?: DirectionDOMRenderer) {
super(name, container, navigator);
@ -181,13 +194,20 @@ export class DirectionComponent extends Component<IDirectionConfiguration> {
}),
distinctUntilChanged())
.subscribe(this._hoveredKeySubject$);
this._emitHoveredKeySubscription = this._hoveredKey$
.subscribe(
(key: string): void => {
this.fire(DirectionComponent.hoveredkeychanged, key);
});
}
protected _deactivate(): void {
this._configurationSubscription.unsubscribe();
this._emitHoveredKeySubscription.unsubscribe();
this._hoveredKeySubscription.unsubscribe();
this._nodeSubscription.unsubscribe();
this._renderCameraSubscription.unsubscribe();
this._hoveredKeySubscription.unsubscribe();
}
protected _getDefaultConfiguration(): IDirectionConfiguration {

View File

@ -53,10 +53,6 @@ import {
Navigator,
} from "../../Viewer";
interface IConfigurationOperation {
(configuration: ISequenceConfiguration): ISequenceConfiguration;
}
/**
* @class SequenceComponent
* @classdesc Component showing navigation arrows for sequence directions
@ -69,11 +65,23 @@ export class SequenceComponent extends Component<ISequenceConfiguration> {
/**
* Event fired when playing starts or stops.
*
* @event PlayerComponent#playingchanged
* @event SequenceComponent#playingchanged
* @type {boolean} Indicates whether the player is playing.
*/
public static playingchanged: string = "playingchanged";
/**
* Event fired when the hovered key changes.
*
* @description Emits the key of the node for the direction
* arrow that is being hovered. When the mouse leaves a
* direction arrow null is emitted.
*
* @event SequenceComponent#hoveredkeychanged
* @type {string} The hovered key, null if no key is hovered.
*/
public static hoveredkeychanged: string = "hoveredkeychanged";
private _sequenceDOMRenderer: SequenceDOMRenderer;
private _scheduler: Scheduler;
@ -81,6 +89,7 @@ export class SequenceComponent extends Component<ISequenceConfiguration> {
private _hoveredKey$: Observable<string>;
private _containerWidth$: Subject<number>;
private _emitHoveredKeySubscription: Subscription;
private _renderSubscription: Subscription;
private _playingSubscription: Subscription;
private _containerWidthSubscription: Subscription;
@ -527,9 +536,16 @@ export class SequenceComponent extends Component<ISequenceConfiguration> {
}),
distinctUntilChanged())
.subscribe(this._hoveredKeySubject$);
this._emitHoveredKeySubscription = this._hoveredKey$
.subscribe(
(key: string): void => {
this.fire(SequenceComponent.hoveredkeychanged, key);
});
}
protected _deactivate(): void {
this._emitHoveredKeySubscription.unsubscribe();
this._renderSubscription.unsubscribe();
this._playingSubscription.unsubscribe();
this._containerWidthSubscription.unsubscribe();