Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is an onBeforeModalClose, can you add an onBeforeModalOpen? #117

Open
a982246809 opened this issue Jun 3, 2024 · 14 comments
Open
Assignees
Labels
Feature Need to do

Comments

@a982246809
Copy link

There is an onBeforeModalClose, can you add an onBeforeModalOpen?

@a982246809 a982246809 added the Feature Need to do label Jun 3, 2024
@Jenesius
Copy link
Owner

Jenesius commented Jun 3, 2024

Hello. What functionality would you like to see in onBeforeModalOpen. I'm using onMounted instead, but if there's a need I'll add it.
As I understand it, you control the opening of the fashion window in the fashion window itself?

@a982246809
Copy link
Author

a982246809 commented Jun 7, 2024

我有一个全局状态 switch , 当switch=false时 , 我希望在全局任意的调用都不会生效
I have a global state switch. When switch=false, I hope that any global call openModal will not take effect.

@Jenesius
Copy link
Owner

Jenesius commented Jun 7, 2024

Okay, I will add it today!

@a982246809
Copy link
Author

可能在vue文件中加onBeforeModalOpen 并不起作用 , 因为一开始并不会初始化
Adding onBeforeModalOpen to the vue file may not work, because it will not be initialized at first

@Jenesius
Copy link
Owner

Jenesius commented Jun 9, 2024

It will looks like it:

import {config} from "jenesius-vue-modal"

config({
  beforeEach() {
    if (global.switch === false) return false;
  }
})

How do you like it? Or add just:

import {beforeEach} from "jenesius-vue-modal"

But this is too general a function, I don't want to clutter up the import space

@Jenesius Jenesius reopened this Jun 10, 2024
@Jenesius
Copy link
Owner

Jenesius commented Jun 10, 2024

Please note version 1.11.7. I added the beforeEach function to the config.

import {config} from "jenesius-vue-modal"

config({
  beforeEach() {
    if (global.switch === false) return false;
  }
})

Thanks for your help in improving the library!

@Jenesius Jenesius self-assigned this Jun 10, 2024
@a982246809
Copy link
Author

thanks , This library is great.

@a982246809
Copy link
Author

Can each Modal be managed individually? For example:
可以对每个Modal进行单独的管理吗 , 例如

config({
    store: {
    Foo: {
       component:FooComp ,
       beforeEach() {
          if (global.switch === false) return false;
        }
    }
   }
})

@a982246809
Copy link
Author

@Jenesius

@Jenesius Jenesius reopened this Jul 11, 2024
@Jenesius
Copy link
Owner

In this case, it is important to understand that this hook will only work when called by name.

I'll try to come up with something and write about it as I go along

@a982246809
Copy link
Author

Can each Modal be managed individually? For example:每个Modal可以单独管理吗?例如: 可以对每个Modal进行单独的管理吗 , 例如

config({
    store: {
    Foo: {
       component:FooComp ,
       beforeEach() {
          if (global.switch === false) return false;
        }
    }
   }
})

backgroundClose also needs to be configured for a separate modal
backgroundClose 也需要对单独的modal进行配置

@Jenesius
Copy link
Owner

I'll try to show the result tomorrow, as long as I have this interface:

export interface IStoreComponentConfiguration {
    component: Component,
    beforeEach: unknown,
    backgroundClose: unknown,
    scrollLock: unknown,
    animation: unknown,
    escClose: unknown,
    draggable: unknown,
}
config({
  store: {
    Foo: IStoreComponentConfiguration 
  }
})

@Jenesius
Copy link
Owner

Now will available only draggable, beforeEach, backgroundClose. The rest will also need to be taken out, but they are not yet located inside the modal window, but are taken directly from the configuration.

@Jenesius Jenesius mentioned this issue Jul 17, 2024
@Jenesius
Copy link
Owner

Version 1.11.9.
Docs

config({
    store: {
        Foo: {
           component:FooComp ,
           beforeEach() {
              if (global.switch === false) return false;
            }
        }
   }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Need to do
Projects
None yet
Development

No branches or pull requests

2 participants