FIX: Safer offset checking

This commit is contained in:
Robin Ward 2016-06-03 17:57:52 -04:00
parent 3ac4a40208
commit eccfa1317a
No known key found for this signature in database
GPG key ID: 0E091E2B4ED1B83D
2 changed files with 8 additions and 2 deletions

View file

@ -24,7 +24,9 @@ export default MountWidget.extend(Docking, {
},
dockCheck(info) {
const topicTop = $('.container.posts').offset().top - $('#main').offset().top;
const mainOffset = $('#main').offset();
const offsetTop = mainOffset ? mainOffset.top : 0;
const topicTop = $('.container.posts').offset().top - offsetTop;
const topicBottom = $('#topic-bottom').offset().top;
const $timeline = this.$('.timeline-container');
const timelineHeight = $timeline.height() || 400;

View file

@ -1,5 +1,9 @@
const helper = {
offset: () => (window.pageYOffset || $('html').scrollTop()) - $('#main').offset().top
offset() {
const mainOffset = $('#main').offset();
const offsetTop = mainOffset ? mainOffset.top : 0;
return (window.pageYOffset || $('html').scrollTop()) - offsetTop;
}
};
export default Ember.Mixin.create({