diff --git a/dribbblish.js b/dribbblish.js index 2816dd8..4c09b32 100644 --- a/dribbblish.js +++ b/dribbblish.js @@ -112,6 +112,10 @@ class ConfigMenu { options.onChange(this.get(options.key)); }); } else if (options.type == "select") { + // Validate + const val = this.get(options.key, options.defaultValue); + if (val < 0 || val > options.data.length - 1) this.set(options.key, options.defaultValue); + const input = /* html */ ` @@ -171,7 +179,11 @@ class ConfigMenu { options.onChange(this.get(options.key)); }); } else if (options.type == "slider") { + // Validate if (options.defaultValue == null) options.defaultValue = 0; + const val = this.get(options.key, options.defaultValue); + if (options.data.min != null && val < options.data.min) this.set(options.key, options.data.min); + if (options.data.max != null && val > options.data.max) this.set(options.key, options.data.max); const input = /* html */ `