{"record":{"id":"a95d2dccd1b888d6","repo":"Dogfalo/materialize","slug":"nouislider-padding-option-must-be-less-than-hal","errorCode":null,"errorMessage":"noUiSlider: 'padding' option must be less than half the range.","messagePattern":"noUiSlider: 'padding' option must be less than half the range\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extras/noUiSlider/nouislider.js","lineNumber":645,"sourceCode":"            throw new Error(\"noUiSlider: 'padding' option must be numeric.\");\n        }\n\n        if ( entry === 0 ) {\n            return;\n        }\n\n        parsed.padding = parsed.spectrum.getMargin(entry);\n\n        if ( !parsed.padding ) {\n            throw new Error(\"noUiSlider: 'padding' option is only supported on linear sliders.\");\n        }\n\n        if ( parsed.padding < 0 ) {\n            throw new Error(\"noUiSlider: 'padding' option must be a positive number.\");\n        }\n\n        if ( parsed.padding >= 50 ) {\n            throw new Error(\"noUiSlider: 'padding' option must be less than half the range.\");\n        }\n    }\n\n    function testDirection ( parsed, entry ) {\n\n        // Set direction as a numerical value for easy parsing.\n        // Invert connection for RTL sliders, so that the proper\n        // handles get the connect/background classes.\n        switch ( entry ) {\n            case 'ltr':\n                parsed.dir = 0;\n                break;\n            case 'rtl':\n                parsed.dir = 1;\n                break;\n            default:\n                throw new Error(\"noUiSlider: 'direction' option was not recognized.\");\n        }","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/Dogfalo/materialize/blob/824e78248b3de81e383445e76ffb04cc3264fe7d/extras/noUiSlider/nouislider.js#L627-L663","documentation":"noUiSlider rejects the 'padding' option when it consumes half or more of the slider range. Padding is converted to a percentage of (max - min) via Spectrum.getMargin -> fromPercentage, and if that percentage is >= 50 the slider can no longer function because the two padded zones would overlap. The library caps padding strictly below the midpoint of the range.","triggerScenarios":"Call noUiSlider.create() with options.padding set to a number whose value is at least half of (range.max - range.min), e.g. range {min:0,max:100} and padding 50, or range {min:0,max:10} and padding 5. Also triggered by an entry of 0 bypassed earlier but a large positive value passing getMargin.","commonSituations":"Developers confuse absolute units with percentages (passing 50 thinking it means 50% rather than 50 units), copy a padding value from a slider with a different range, or increase padding while narrowing the range. Hitting this after refactoring a range from a wide span to a small one is common.","solutions":["Reduce padding to strictly less than half of (range.max - range.min), e.g. for range 0-100 use padding <= 49.","If you actually want a large dead zone, widen the range so padding is < 50% of it.","Re-read padding as an absolute value in range units (not a percentage) before retrying."],"exampleFix":"// before\nnoUiSlider.create(el, { start: 50, range: { min: 0, max: 100 }, padding: 50 });\n// after\nnoUiSlider.create(el, { start: 50, range: { min: 0, max: 100 }, padding: 20 });","handlingStrategy":"validation","validationCode":"function assertPadding(opts) {\n  if (opts.padding == null || opts.padding === 0) return;\n  const span = opts.range.max - opts.range.min;\n  if (Math.abs(opts.padding) >= span / 2) {\n    throw new RangeError(`padding ${opts.padding} must be < half the range span (${span/2})`);\n  }\n}","typeGuard":"function isValidPadding(opts) {\n  const span = opts.range.max - opts.range.min;\n  return typeof opts.padding === 'number' && opts.padding >= 0 && opts.padding < span / 2;\n}","tryCatchPattern":null,"preventionTips":["Always compute padding relative to (range.max - range.min), never as a percentage.","Centralize range/padding in a shared config object so changes stay consistent.","Unit-test slider configs across the range of padding values you support."],"tags":["nouislider","validation","configuration","range"],"backgroundTag":null,"analyzedSha":"824e78248b3de81e383445e76ffb04cc3264fe7d","analyzedAt":"2026-08-13T04:14:22.506Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}