Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/pickr.es5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/pickr.es5.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/pickr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/pickr.min.js.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/js/pickr.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class Pickr {
_lastColor = HSVaColor();
_swatchColors = [];

// Destroy flag
_destroyed = false;

// Evenlistener name: [callbacks]
_eventListener = {
init: [],
Expand Down Expand Up @@ -143,6 +146,11 @@ class Pickr {
const that = this;
requestAnimationFrame((function cb() {

// If somehow Pickr DOM is deleted/destroyed before even rendered by browser, then stop
if (that._destroyed) {
return;
}

// TODO: Performance issue due to high call-rate?
if (!app.offsetWidth) {
return requestAnimationFrame(cb);
Expand Down Expand Up @@ -697,6 +705,9 @@ class Pickr {

Object.keys(this._components)
.forEach(key => this._components[key].destroy());

// Leaving _destroyed as a flag for TODO problem
this._destroyed = true;
}

/**
Expand All @@ -719,6 +730,9 @@ class Pickr {
// This cleans all of them to avoid detached DOMs
Object.keys(this)
.forEach(key => this[key] = null);

// Leaving _destroyed as a flag for TODO problem
this._destroyed = true;
}

/**
Expand Down