[improvement] Notify: improve event binding (#3640)

This commit is contained in:
neverland 2019-06-26 14:26:03 +08:00 committed by GitHub
parent c6f8fca41f
commit 344b105e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { use } from '../utils';
import { RED, WHITE } from '../utils/color';
import { emit, inherit } from '../utils/functional';
import { inherit } from '../utils/functional';
import { PopupMixin } from '../mixins/popup';
import Popup from '../popup';
@ -38,16 +38,7 @@ function Notify(
overlay={false}
lockScroll={false}
class={[bem(), props.className]}
onInput={(value: boolean) => {
emit(ctx, 'input', value);
}}
onClick={(event: Event) => {
emit(ctx, 'click', event);
}}
onOpened={() => {
emit(ctx, 'opened');
}}
{...inherit(ctx)}
{...inherit(ctx, true)}
>
{props.message}
</Popup>

View File

@ -26,6 +26,11 @@ function Notify(options: NotifyOptions) {
instance.onClick(event);
}
},
close() {
if (instance.onClose) {
instance.onClose();
}
},
opened() {
if (instance.onOpened) {
instance.onOpened();
@ -67,10 +72,6 @@ function defaultOptions(): NotifyOptions {
Notify.clear = () => {
if (instance) {
instance.value = false;
if (instance.onClose) {
instance.onClose();
}
}
};