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

Upgrade to 3.0 and remove jquery usage #121

Merged
merged 16 commits into from
Feb 24, 2018
Merged

Upgrade to 3.0 and remove jquery usage #121

merged 16 commits into from
Feb 24, 2018

Conversation

snewcomer
Copy link
Collaborator

@snewcomer snewcomer commented Feb 5, 2018

Still got some work to do here. Previous implementation for scroll listeners did something to the effect of scroll.elementId whereas now it just simply listens for scroll. Need to look into if this could break anything.

  • upgrade to 3.0
  • replace usage of jquery
  • properly remove jquery

Closes #118

@snewcomer snewcomer self-assigned this Feb 5, 2018
viewportOptionsOverride: Ember.on('didInsertElement', function() {
init() {
this._super(...arguments);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on eslint's rule no-function-prototype-extensions

$(context).off(`scroll.directional#${elementId}`);
elem.removeEventListener('scroll', () => {
this._debouncedEventHandler('_triggerDidScrollDirection', elem, get(this, 'viewportScrollSensitivity'));
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure of the implications of this. It wouldn't be good if the removeEventListener matching algorithm didn't match....so maybe I should put the callback as a method on the mixin instead of repeating it in the addEventListener callback.


$contextEl.on(`scroll.directional#${get(this, 'elementId')}`, () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also concerned about the use of elementId here. Perhaps this was there to solve a use case where this mixin was used on many components on a page. So potentially, with this PR, there are multiple listeners on the window object.

@bkoval
Copy link

bkoval commented Feb 6, 2018

I'm getting Uncaught DOMException: Failed to construct 'IntersectionObserver': rootMargin must be specified in pixels or percent. When trying out the branch -> this is due to _viewportTolerance.left and .right being undefined. (newest desktop Chrome emulating Nexus 6p).

@snewcomer
Copy link
Collaborator Author

@bkoval What do you have set for the viewportTolerance, if anything? The browser automated tests aren't showing anything. Just tried this branch out as well on 4200.

Note: one thing I did notice is that we aren't allowing users to specify %'s for the viewport tolerance 😱

https://github.com/DockYard/ember-in-viewport/blob/master/addon/mixins/in-viewport.js#L104

@bkoval
Copy link

bkoval commented Feb 6, 2018

@snewcomer I am just setting top and bottom. Could it be that on master ember-in-viewport uses defaults in such case?

@snewcomer
Copy link
Collaborator Author

@bkoval would you mind pasting your viewportTolerance config?

@bkoval
Copy link

bkoval commented Feb 7, 2018

Sure:

const viewportTolerance = 1000;
  
this.set('viewportTolerance', {
    top: viewportTolerance,
    bottom: viewportTolerance
});

@snewcomer
Copy link
Collaborator Author

@bkoval Welp, you are completely correct. Sry about that. Put a PR in to fix. In the meantime, if your config looked like this, it should work. Thanks for reporting this bug!

this.set('viewportTolerance', {
    top: viewportTolerance,
    bottom: viewportTolerance,
    right: 0,
    left: 0
});

@snewcomer snewcomer force-pushed the upgrade branch 2 times, most recently from fff4785 to 7afa74f Compare February 12, 2018 14:58
@snewcomer snewcomer changed the title Upgrade to 2.18 and remove jquery usage Upgrade to 3.0 and remove jquery usage Feb 16, 2018
@snewcomer
Copy link
Collaborator Author

Tested this branch out on our app and works 👍 . Anybody else wanna give it a go?

@snewcomer snewcomer merged commit 4319f8a into master Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants