mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-21 04:52:54 -05:00
38 lines
921 B
JavaScript
38 lines
921 B
JavaScript
const helper = {
|
|
offset() {
|
|
const mainOffset = $('#main').offset();
|
|
const offsetTop = mainOffset ? mainOffset.top : 0;
|
|
return (window.pageYOffset || $('html').scrollTop()) - offsetTop;
|
|
}
|
|
};
|
|
|
|
export default Ember.Mixin.create({
|
|
queueDockCheck: null,
|
|
|
|
init() {
|
|
this._super();
|
|
this.queueDockCheck = () => {
|
|
Ember.run.debounce(this, this.safeDockCheck, 5);
|
|
};
|
|
},
|
|
|
|
safeDockCheck() {
|
|
if (this.isDestroyed || this.isDestroying) { return; }
|
|
this.dockCheck(helper);
|
|
},
|
|
|
|
didInsertElement() {
|
|
this._super();
|
|
|
|
$(window).bind('scroll.discourse-dock', this.queueDockCheck);
|
|
$(document).bind('touchmove.discourse-dock', this.queueDockCheck);
|
|
|
|
this.dockCheck(helper);
|
|
},
|
|
|
|
willDestroyElement() {
|
|
this._super();
|
|
$(window).unbind('scroll.discourse-dock', this.queueDockCheck);
|
|
$(document).unbind('touchmove.discourse-dock', this.queueDockCheck);
|
|
}
|
|
});
|