mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
Store bound handlers in this
This commit is contained in:
committed by
Franz Liedke
parent
8cc9e18990
commit
aceac88013
@@ -24,11 +24,12 @@ export default class ConfirmDocumentUnload extends Component {
|
||||
oncreate(vnode) {
|
||||
super.oncreate(vnode);
|
||||
|
||||
$(window).on('beforeunload', this.handler.bind(this));
|
||||
this.boundHandler = this.handler.bind(this);
|
||||
$(window).on('beforeunload', this.boundHandler);
|
||||
}
|
||||
|
||||
onremove() {
|
||||
$(window).off('beforeunload', this.handler.bind(this));
|
||||
$(window).off('beforeunload', this.boundHandler);
|
||||
}
|
||||
|
||||
view(vnode) {
|
||||
|
@@ -5,8 +5,8 @@ export default class AffixedSidebar extends Component {
|
||||
return vnode.children[0];
|
||||
}
|
||||
|
||||
onresize(vnode) {
|
||||
const $sidebar = $(vnode.dom);
|
||||
onresize() {
|
||||
const $sidebar = this.$();
|
||||
const $header = $('#header');
|
||||
const $footer = $('#footer');
|
||||
const $affixElement = $sidebar.find('> ul');
|
||||
@@ -30,10 +30,11 @@ export default class AffixedSidebar extends Component {
|
||||
super.oncreate(vnode);
|
||||
|
||||
// Register the affix plugin to execute on every window resize (and trigger)
|
||||
$(window).on('resize', this.onresize.bind(this, vnode)).resize();
|
||||
this.boundOnresize = this.onresize.bind(this);
|
||||
$(window).on('resize', this.boundOnresize).resize();
|
||||
}
|
||||
|
||||
onremove(vnode) {
|
||||
$(window).off('resize', this.onresize.bind(this, vnode));
|
||||
onremove() {
|
||||
$(window).off('resize', this.boundOnresize);
|
||||
}
|
||||
}
|
||||
|
@@ -84,21 +84,21 @@ export default class Composer extends Component {
|
||||
// When the escape key is pressed on any inputs, close the composer.
|
||||
this.$().on('keydown', ':input', 'esc', () => this.close());
|
||||
|
||||
const handlers = {};
|
||||
this.handlers = {};
|
||||
|
||||
$(window)
|
||||
.on('resize', (handlers.onresize = this.updateHeight.bind(this)))
|
||||
.on('resize', (this.handlers.onresize = this.updateHeight.bind(this)))
|
||||
.resize();
|
||||
|
||||
$(document)
|
||||
.on('mousemove', (handlers.onmousemove = this.onmousemove.bind(this)))
|
||||
.on('mouseup', (handlers.onmouseup = this.onmouseup.bind(this)));
|
||||
.on('mousemove', (this.handlers.onmousemove = this.onmousemove.bind(this)))
|
||||
.on('mouseup', (this.handlers.onmouseup = this.onmouseup.bind(this)));
|
||||
}
|
||||
|
||||
onremove() {
|
||||
$(window).off('resize', handlers.onresize);
|
||||
$(window).off('resize', this.handlers.onresize);
|
||||
|
||||
$(document).off('mousemove', handlers.onmousemove).off('mouseup', handlers.onmouseup);
|
||||
$(document).off('mousemove', this.handlers.onmousemove).off('mouseup', this.handlers.onmouseup);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -100,14 +100,15 @@ export default class NotificationList extends Component {
|
||||
const $notifications = this.$('.NotificationList-content');
|
||||
const $scrollParent = $notifications.css('overflow') === 'auto' ? $notifications : $(window);
|
||||
|
||||
$scrollParent.on('scroll', this.scrollHandler.bind(this));
|
||||
this.boundScrollHandler = this.scrollHandler.bind(this);
|
||||
$scrollParent.on('scroll', this.boundScrollHandler);
|
||||
}
|
||||
|
||||
onremove() {
|
||||
const $notifications = this.$('.NotificationList-content');
|
||||
const $scrollParent = $notifications.css('overflow') === 'auto' ? $notifications : $(window);
|
||||
|
||||
$scrollParent.off('scroll', this.scrollHandler.bind(this));
|
||||
$scrollParent.off('scroll', this.boundScrollHandler);
|
||||
}
|
||||
|
||||
scrollHandler() {
|
||||
|
Reference in New Issue
Block a user