Skip to content

Commit

Permalink
work for #8112 Drop-down. Full list appears in the moment of selecting.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed May 17, 2024
1 parent 986f678 commit eb5cfb2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
16 changes: 12 additions & 4 deletions src/popup-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ export class PopupBaseViewModel extends Base implements IAnimationConsumer {
this.onVisibilityChanged.fire(this, { isVisible: val });
}

private updateBeforeShowing(): void {
this.model.onShow();
}
private updateAfterHiding(): void {
this.model.onHiding();
}
private visibilityAnimation: AnimationBoolean = new AnimationBoolean(this, (val) => {
if(this._isVisible !== val) {
if(!val) {
this.updateOnHiding();
this.updateIsVisible(val);
this.updateAfterHiding();
this._isPositionSetValue = false;
}
else {
this.updateBeforeShowing();
this.updateIsVisible(val);
}
}
Expand All @@ -55,20 +63,20 @@ export class PopupBaseViewModel extends Base implements IAnimationConsumer {
getAnimatedElement(): HTMLElement {
return this.getAnimationContainer();
}
isAnimationEnabled (): boolean {
isAnimationEnabled(): boolean {
return this.model.displayMode !== "overlay" && settings.animationEnabled;
}

private getAnimationContainer(): HTMLElement {
return <HTMLElement>this.container?.querySelector(this.fixedPopupContainer);
}

public set isVisible(val: boolean) {
this.visibilityAnimation.sync(val);
}
public get isVisible(): boolean {
return this._isVisible;
}
public set isVisible(val: boolean) {
this.visibilityAnimation.sync(val);
}

public onVisibilityChanged = new EventBase<PopupBaseViewModel, any>();

Expand Down
10 changes: 4 additions & 6 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ export class PopupModel<T = any> extends Base implements IPopupOptionsBase {
}
this.setPropertyValue("isVisible", value);
this.onVisibilityChanged.fire(this, { model: this, isVisible: value });
if (this.isVisible) {
this.onShow();
} else {
this.refreshInnerModel();
this.onHide();
}
}
public toggleVisibility(): void {
this.isVisible = !this.isVisible;
Expand All @@ -103,6 +97,10 @@ export class PopupModel<T = any> extends Base implements IPopupOptionsBase {
this.onFooterActionsCreated.fire(this, options);
return options.actions;
}
public onHiding(): void {
this.refreshInnerModel();
this.onHide();
}
public dispose(): void {
super.dispose();
this.onDispose();
Expand Down
6 changes: 2 additions & 4 deletions tests/components/popuptests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,8 @@ QUnit.test("PopupViewModel dispose", (assert) => {
trace += "->onShow";
};

model.toggleVisibility();
//viewModel.isVisible(!viewModel.isVisible());
assert.equal(trace, "->onShow");

model.isVisible = true;
assert.equal(trace, "");
assert.equal(!!viewModel.container, false);
assert.equal(container.tagName, "DIV");
assert.notEqual(container.innerHTML.indexOf('<div class="sv-popup"'), 0);
Expand Down

0 comments on commit eb5cfb2

Please sign in to comment.