From 53fdf0a0fdc87f9490cdd204c9099702ea5338d4 Mon Sep 17 00:00:00 2001 From: Chris Boustead Date: Wed, 15 Nov 2017 16:05:28 -0500 Subject: [PATCH] Add detach api method to remove plugin from player --- package.json | 2 +- src/plugin.js | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5a934f6..61e2e10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-vtt-thumbnails", - "version": "0.0.2", + "version": "0.0.3", "description": "Display thumnails on progress bar hover, driven by external VTT files.", "main": "dist/videojs-vtt-thumbnails.cjs.js", "module": "dist/videojs-vtt-thumbnails.es.js", diff --git a/src/plugin.js b/src/plugin.js index b114e67..c50a1b0 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -73,15 +73,23 @@ class vttThumbnailsPlugin { } src(source){ - delete this.vttData; - delete this.thumbnailHolder; - delete this.lastStyle; + this.resetPlugin(); + this.options.src = source; + this.initializeThumbnails(); + } + + detach() { + this.resetPlugin(); + } + + resetPlugin() { this.progressBar.removeEventListener('mouseenter',() => { return this.onBarMouseenter() }); this.progressBar.removeEventListener('mouseleave',() => { return this.onBarMouseleave() }); this.progressBar.removeEventListener('mousemove',this.onBarMousemove); delete this.progressBar; - this.options.src = source; - this.initializeThumbnails(); + delete this.vttData; + delete this.thumbnailHolder; + delete this.lastStyle; } /**