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

Component doesn't update on screen resize #15

Open
estshy opened this issue Sep 20, 2016 · 0 comments
Open

Component doesn't update on screen resize #15

estshy opened this issue Sep 20, 2016 · 0 comments

Comments

@estshy
Copy link

estshy commented Sep 20, 2016

Component should be recalculating sticky dimension and position on document resize, otherwise it doesn't work correctly with RWD.

import Ember from 'ember';
import StickyContainer from 'ember-cli-sticky/components/sticky-container';

const WINDOW = Ember.$(window);

export default StickyContainer.extend({
  addResizeHandler: Ember.on('didInsertElement', function() {
    const updateSticky = () => this.$().sticky('update');

    WINDOW.on('resize.sticky-container', () => {
      Ember.run.debounce(this, updateSticky, 100);
    });
  }),

  detachResizeHandler: Ember.on('willDestroyElement', function() {
    WINDOW.off('.sticky-container');
  })
});

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

1 participant