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

Access window and documents in function scope #94

Closed
meteorlxy opened this issue Mar 20, 2019 · 2 comments
Closed

Access window and documents in function scope #94

meteorlxy opened this issue Mar 20, 2019 · 2 comments

Comments

@meteorlxy
Copy link
Contributor

Bug description

In v0.4.0, we only try to access window / document in the function scope, i.e. all related code is wraped in the mediumZoom function:

const mediumZoom = (
selector,
{
margin = 0,
background = '#fff',
scrollOffset = 48,
metaClick = true,
container,
template
} = {}
) => {

In v1.x, we access window / document outside the mediumZoom function:

const Promise =
window.Promise ||
function Promise(fn) {
function noop() {}
fn(noop, noop)
}
const mediumZoom = (selector, options = {}) => {

I'm using medium-zoom in a server-rendered project, but window / document can only be accessed in client. The differences cause errors when I try to migrate to v1.x from v0.4.0.

If it won't be fixed, I think it is one of the breaking changes that should be listed.

@francoischalifour
Copy link
Owner

Thanks for filing an issue.

There's a simple fix to this without actual tradeoff so we might actually want to add support for SSR here.

Would you mind opening a PR?

@meteorlxy
Copy link
Contributor Author

With pleasure 😄

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

2 participants