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

Automatically handle image state sync per default #59

Open
nomego opened this issue Apr 29, 2019 · 3 comments
Open

Automatically handle image state sync per default #59

nomego opened this issue Apr 29, 2019 · 3 comments
Assignees

Comments

@nomego
Copy link
Contributor

nomego commented Apr 29, 2019

We are currently using multiple instances of this component but they should share external window (when used).

We should introduce a behavior where we observe isAttached along with isVisible and call syncImageState() whenever any of them changes into a state where both are true:

Pseudo-code:

static get properties() {
  isVisible: {
    type: Boolean,
    readOnly: true
  },
  manualImageStateSync: {
    type: Boolean,
    value: false
  }
  ...
}

static get observers() {
  return [
    'autoSyncImageState(isAttached, isVisible, manualImageStateSync)'
  ];
}

...

_onResize(event) {
  this._setIsVisible(Boolean(this.offsetWidth || this.offsetHeight));
  ...
}

autoSyncImageState(isAttached, isVisible, manualImageStateSync) {
  if (isAttached && isVisible && !manualImageStateSync) {
    this.syncImageState();
  }
}
@cristinecula
Copy link
Collaborator

@nomego the problem is that we don't have a reliable way of knowing when the element becomes invisible again. This is a problem when you navigate forwards through the queue and the go backwards. The isVisible prop will remain true and the image viewer will not update.

@nomego
Copy link
Contributor Author

nomego commented Apr 29, 2019

This is true. Would it make sense for cosmoz-tabs to fire an iron-resize on the just-hidden tab?

@cristinecula
Copy link
Collaborator

If we use ResizeObserver we can reliable detect when the element becomes visible.

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

No branches or pull requests

3 participants