videojs-panorama icon indicating copy to clipboard operation
videojs-panorama copied to clipboard

Canvas.handleDispose function doing nothing

Open moshest opened this issue 7 years ago • 2 comments

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));
}

moshest avatar May 29 '17 14:05 moshest

Hey, handleDispose will be triggered via videojs's dispose function.

yanwsh avatar Jun 08 '17 06:06 yanwsh

@yanwsh I'm saying that the method handleDispose isn't working properly.

moshest avatar Jun 08 '17 08:06 moshest