| 1017 | } |
| 1018 | |
| 1019 | destroy() { |
| 1020 | this.notifyPlugins('beforeDestroy'); |
| 1021 | const {canvas, ctx} = this; |
| 1022 | |
| 1023 | this._stop(); |
| 1024 | this._doResize.cancel(); |
| 1025 | this.config.clearCache(); |
| 1026 | |
| 1027 | if (canvas) { |
| 1028 | this.unbindEvents(); |
| 1029 | clearCanvas(canvas, ctx); |
| 1030 | this.platform.releaseContext(ctx); |
| 1031 | this.canvas = null; |
| 1032 | this.ctx = null; |
| 1033 | } |
| 1034 | |
| 1035 | delete instances[this.id]; |
| 1036 | |
| 1037 | this.notifyPlugins('afterDestroy'); |
| 1038 | } |
| 1039 | |
| 1040 | toBase64Image(...args) { |
| 1041 | return this.canvas.toDataURL(...args); |