darul75 / angular-awesome-slider

:arrows_clockwise: Angular slider control directive
http://darul75.github.io/angular-awesome-slider/
MIT License
144 stars 63 forks source link

Get the selected value as slicer is moving #16

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi,

Thanks a lot for sharing this useful module.

I would like to get the value updated as the slicer is moving. So far I have been only able to get the selected value once the user has released the slider. Is there any simple way to have the selected value updated dynamically in the scope of my controller?

Thanks!

darul75 commented 10 years ago

first thank you @melonista, as it is always tricky to integrate such a big stuff ;)

nice idea I will check what can be done.

but as it will probably trigger many events, maybe it will be an option to put at init phase.

I give you details soon

ghost commented 10 years ago

Thanks for your fast reply, I will use it as it is and I will stay tuned for future updates.

lewang commented 10 years ago

@melonista You can link up the onstatechange callback that the jQuery plugin already offers and it just works.

xqjibz commented 10 years ago

Has anyone else been able to make onstatechange work? I have the following options:

$scope.sliderOptions = {
            from    : 0
        ,   to      : 255
        ,   step    : 1
        ,   onstatechange : function(value) { console.log('new value is: ' + value)}
    }

with the following line in my angular app (using a jade template)

input(ng-model="light.pwmValue", type='text', id='mySlider{{$index}}', slider options='sliderOptions')

and the function isn't being called. Am I missing something fundamental?

darul75 commented 10 years ago

hi @xqjibz , i am not sure to get time to figure out what's happening today, can you try to force id with no dynamic $index first ?

xqjibz commented 10 years ago

OK, I tried that, that did not work. I found this: https://github.com/darul75/ng-slider/blob/master/src/ng-slider.js#L78-L79 and that seems to be missing the onstatechange. What I did here is:

                        if (scope.options.calculate)
                            OPTIONS.calculate = scope.options.calculate;
                        if (scope.options.onstatechange)
                            OPTIONS.onstatechange = scope.options.onstatechange;

What I do not know, is if this is the proper way to fix this or not, or if this is the way you had originally intended for this to work.

If you're amenable, I'd be more than happy to put in a PR, and/or open a new issue or something to clarify this a bit more.

darul75 commented 10 years ago

yeah that is the solution for sure, do not hesitate to make a PR to fix it

xqjibz commented 10 years ago

@darul75 PR is issued. If I've missed anything, or you need the version bumped, let me know.