jQRangeSlider icon indicating copy to clipboard operation
jQRangeSlider copied to clipboard

Indicate which handle was manipulated on change.

Open snkashis opened this issue 11 years ago • 14 comments

Provides a 'lastHandle' parameter that is part of 'trigger' which will be left,middle or right.

Demo page updated.

Fixes #67

snkashis avatar Apr 10 '13 09:04 snkashis

Thanks for your pull request.

Can you create tests for this new feature? I'll be glad to integrate it once tested.

Thanks.

ghusse avatar Apr 11 '13 21:04 ghusse

Thanks for your modifications.

Can you test the 3 possible values? After that, I'll merge your request.

ghusse avatar Apr 15 '13 08:04 ghusse

I'm having some difficulty with the async nature of these tests...that is, properly ending each test and moving on to the next one.I try to unbind the event after the first callback but it doesn't seem to be working.The test results 'fall thru' to the next one in line. ideas?

I thought the callback should be like $(el).off('valuesChanging'); QUnit.equal(data.lastHandle,'right', "Last Handle should be right"); start()

snkashis avatar Apr 15 '13 20:04 snkashis

I suggest you to write your test the other way around.

  1. Bind your event
  2. Change the values
  3. Check that you callback had been called.

If you change values before setting up the binding, you'll not be able to catch the event.

ghusse avatar Apr 15 '13 21:04 ghusse

Can I do something to help you with this pull request? Are you stuck on something?

ghusse avatar Apr 17 '13 19:04 ghusse

So the code I listed above was the callback I'm using for valuesChanging...so I am already doing what you are suggesting I believe...but the problem is I cannot seem to stop the event firing after the first time, and so the events 'fall down'. Take a look at my newest commit to see what I mean. The "Issue 12" test seems to catch the handle drag firing and thinks its part of its test.

snkashis avatar Apr 20 '13 02:04 snkashis

I suggest you to move all your code in the first method.

In the second method, verify that your callback was called (because your test will be OK even if the event was not fired at all).

It should do the job.

ghusse avatar Apr 20 '13 19:04 ghusse

Ok, I ran your test, and I know what's going wrong:

  1. I had to transform it to run it correctly:
var handleLeftTest = new TestCase(
    "Handle left",
    function(){
            var self = this;

        $(el).on('valuesChanging', function(e,data) {
            self.leftResult = data.lastHandle;
        });

        var leftHandle = el.find(".ui-rangeSlider-leftHandle");

        setTimeout(function(){
            leftHandle.simulate("drag", {
                dx: el.find(".ui-rangeSlider-container").innerWidth() - leftHandle.position().left,
                dy: 0
            });
        }, 100);

        this.delay = 500;
    },
    function(){
        QUnit.equal(this.leftResult,'left', "Last Handle should be left");
    }
);
  1. Now it fails, but it seems to be ok for me, because the left handle is dragged totally on the right. There is a moment where it becomes the right handle. And your code returns "middle" in this case.

ghusse avatar May 01 '13 12:05 ghusse

Hi, any updates on this ? It would indeed be quite useful for some advanced uses.

vperron avatar Jun 07 '14 08:06 vperron

Any updates?? I'd love to see it work

Davidkulpe avatar Jun 08 '14 06:06 Davidkulpe

For the moment, tests are failing. I don't have any other updates on the subject.

ghusse avatar Jun 12 '14 09:06 ghusse

Hi Guillaume; Great control, 10x for sharing it. I've managed to do it for my purpose. I needed to have two spinners for changing the handlers value by single step, using some code I have it fully functional. I't won't suit the general product

[image: Inline image 1]

Thank again, David

On Thu, Jun 12, 2014 at 12:21 PM, Guillaume Gautreau < [email protected]> wrote:

For the moment, tests are failing. I don't have any other updates on the subject.

— Reply to this email directly or view it on GitHub https://github.com/ghusse/jQRangeSlider/pull/101#issuecomment-45847086.

Davidkulpe avatar Jun 12 '14 09:06 Davidkulpe

I can't see the image, but I'm glad you managed to do it on your own.

ghusse avatar Jun 12 '14 09:06 ghusse

@ghusse let me see if I can jump back into this over the next few days and submit a revised pull. Sorry for the delay.

snkashis avatar Jun 12 '14 16:06 snkashis