discourse/app/assets/javascripts/discourse/mixins/docking.js.es6
2016-05-31 10:51:55 -04:00

30 lines
687 B
JavaScript

const helper = {
offset: () => window.pageYOffset || $('html').scrollTop()
};
export default Ember.Mixin.create({
queueDockCheck: null,
init() {
this._super();
this.queueDockCheck = () => {
Ember.run.debounce(this, this.dockCheck, helper, 20);
};
},
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);
}
});