yanwsh / videojs-panorama

a plugin for videojs run a full 360 degree panorama video.
http://yanwsh.github.io/videojs-panorama/
Other
483 stars 160 forks source link

Canvas.handleDispose function doing nothing #100

Open moshest opened 7 years ago

moshest commented 7 years ago

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));
}
yanwsh commented 7 years ago

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

moshest commented 7 years ago

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