vasyabigi / angular-nouislider

Simple angular directive for jquery nouislider plugin
http://vasyabigi.github.io/angular-nouislider/
MIT License
84 stars 53 forks source link

Error: noUiSlider: 'margin' option is only supported on linear sliders. #25

Open emersonthis opened 9 years ago

emersonthis commented 9 years ago

The bower installation couldn't find suitable version for angular, and maybe nouislider too (can't remember). So I left the versions I was already using (listed above)

Commenting/removing line 29 from nouislider.js seems to resolve the issue:

margin: parseFloat(scope.margin || 0),

It seems that this option is causing errors in recent versions of nouislider, because when I leave it in I get the following error:

Error: noUiSlider: 'margin' option is only supported on linear sliders.
dnlmzw commented 9 years ago

I'm experiencing this as well.

Commenting/removing line 29 from nouislider.js seems to resolve the issue:

Works as a fix, yes. But I guess it is not optimal if you're using the property - or as I am, working on a project with multiple people where vendor files are not added to the codebase.

emersonthis commented 9 years ago

I figured out what's going on here. When the margin setting is absent or zero a false value is passed to testMargin() in jquery.nouislider.js line 489:

    function testMargin ( parsed, entry ) {

        if ( !isNumeric(entry) ){
            throw new Error("noUiSlider: 'margin' option must be numeric.");
        }

        parsed.margin = parsed.spectrum.getMargin(entry);

        if ( !parsed.margin ) {
            throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.");
        }
    }

If you pass a margin value via the attribute then the error doesn't happen. So my earlier hack is unnecessary if you do want a margin. If you don't, you can comment out that line until there's a patch.