videojs-panorama
videojs-panorama copied to clipboard
Canvas.handleDispose function doing nothing
The code of handleDispose()
is someting like:
handleDispose: function handleDispose(event) {
this.off('mousemove', this.handleMouseMove.bind(this));
this.off('touchmove', this.handleTouchMove.bind(this));
...
}
Witch is useless becasue .bind()
creates a new function on each call so the .off()
method can't find the original functions what added via the .on()
method.
A solution for this problem may be something like this:
attachControlEvents: function handleDispose(event) {
this.on('mousemove', this, this.handleMouseMove);
this.on('touchmove', this, this.handleTouchMove);
// ...
}
handleDispose: function handleDispose(event) {
this.off('mousemove', this, this.handleMouseMove);
this.off('touchmove', this, this.handleTouchMove);
// ...
}
In addition, handleDispose
do not remove this event that was binded on the constructor
:
constructor: function init(player, options) {
// ...
this.player().on("play", function () {
this.time = new Date().getTime();
this.startAnimation();
}.bind(this));
}
Hey, handleDispose will be triggered via videojs's dispose function.
@yanwsh I'm saying that the method handleDispose
isn't working properly.