Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate which handle was manipulated on change. #101

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

snkashis
Copy link

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

Demo page updated.

Fixes #67

@ghusse
Copy link
Owner

ghusse commented Apr 11, 2013

Thanks for your pull request.

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

Thanks.

@ghusse
Copy link
Owner

ghusse commented Apr 15, 2013

Thanks for your modifications.

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

@snkashis
Copy link
Author

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()

@ghusse
Copy link
Owner

ghusse commented Apr 15, 2013

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
Copy link
Owner

ghusse commented Apr 17, 2013

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

@snkashis
Copy link
Author

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.

@ghusse
Copy link
Owner

ghusse commented Apr 20, 2013

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
Copy link
Owner

ghusse commented May 1, 2013

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.

@vperron
Copy link

vperron commented Jun 7, 2014

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

@Davidkulpe
Copy link

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

@ghusse
Copy link
Owner

ghusse commented Jun 12, 2014

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

@Davidkulpe
Copy link

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
#101 (comment).

@ghusse
Copy link
Owner

ghusse commented Jun 12, 2014

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

@snkashis
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Track which side of the slider a user clicked on.
4 participants