mirror of
https://github.com/discourse/discourse.git
synced 2025-02-10 08:15:17 +08:00
30 lines
687 B
JavaScript
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);
|
|
}
|
|
});
|