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

Option function for customizing modal dimensions #1831

Open
wbobeirne opened this issue Mar 1, 2022 · 4 comments
Open

Option function for customizing modal dimensions #1831

wbobeirne opened this issue Mar 1, 2022 · 4 comments

Comments

@wbobeirne
Copy link

wbobeirne commented Mar 1, 2022

Hey there, loving Sheperd.js so far. I've got an element I want to highlight that has an unusual height calculation due to being a list of unknown size. I'd love to be able to have my own custom function for determining modal size. Ideally it'd be called right after openingProperties is assigned and just let me modify the object directly, or return a new object. Something like:

const tour = new Shepherd.Tour({
  useModalOverlay: true,
  defaultStepOptions: {
    modalOverlayPosition: (props) => {
      // Set maximum overlay size to window height minus padding
      props.height = Math.min(props.height, window.innerHeight - 40);
    },
  }
});

Just an example, not my exact use case.

@RobbieTheWagner
Copy link
Member

@wbobeirne glad to hear you are loving Shepherd! Perhaps there is something I am missing here, but couldn't you just target the parent of your list of unknown size? Then you wouldn't need to know the size at all.

@wbobeirne
Copy link
Author

Made a quick diagram, hope this explains it:
Frame 1 (14)

And in my case, I want it to be a subset of the items. It can be tricky to do that wrapping though without totally mangling my flexbox styles. I could probably hack around this by making a special absolute positioned element for the area I want to cover, but it seemed like a not-that-unusual case to want to do some overriding of the dimensions of the cover, so I figured this might be a better route to go.

@RobbieTheWagner
Copy link
Member

@wbobeirne thanks for the explanation! I think it is reasonable to support what you are asking about. Would you be interested in opening a PR?

@Steezli
Copy link
Contributor

Steezli commented Aug 16, 2022

#1837

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

No branches or pull requests

3 participants