Skip to content

Draggable range #100

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

Merged
merged 1 commit into from
Aug 19, 2015
Merged

Draggable range #100

merged 1 commit into from
Aug 19, 2015

Conversation

coxm
Copy link
Contributor

@coxm coxm commented Aug 12, 2015

Adds an option to make the range draggable when in use.

this.minH.addClass('rz-active');
this.maxH.addClass('rz-active');

this.onStart(pointer, ref, event, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the active: true property? It's used in onStart to determine which move handler (onMove or onDragMove) is used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I thought the comment was attached to a unique line...
I was talking about the true in:
this.onStart(pointer, ref, event, true);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a mistake. Originally I was passing an extra argument to onStart, but now it's using this.dragging.active. I'll remove the extra true.

@ValentinH
Copy link
Member

Thanks for this PR, this is a pretty cool work!

Just a few remarks:

  • the model is not updated when dragging the range (inside the text inputs): I think you forgot a this.scope.$apply()
  • the name of the option attribute is too generic. Why not something like rz-slider-draggable-range?
  • dragging shouldn't only work when clicking on the selection bar? Now it works when clicking outside of it too... Feels pretty weird to me.
  • remarks directly in code comments

@@ -508,6 +529,13 @@ function throttle(func, wait, options) {
this.maxH.remove();
this.selBar.remove();
}

// If using draggable range, use appropriate cursor for this.fullBar.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.fullbar -> this.selBar

@coxm
Copy link
Contributor Author

coxm commented Aug 12, 2015

Cool, thanks!

  • You're right about the scope.$apply(); I'll add this in.
  • OK, I agree that rz-slider-draggable-range is better.
  • I hadn't noticed this; I'll fix it soon.
  • I'll address these in the code comments

@coxm
Copy link
Contributor Author

coxm commented Aug 13, 2015

I think that's everything!

@ValentinH
Copy link
Member

Yeap this looks good to me.

One last remark: now if you click just above the range, the min handle moves. I think that the perfect behaviour would be to drag the range bar when clicking between the min and max handles.

Currently, the handle the clicks outside the bars, we have a bar wrapper to enlarge the clickable zone. Maybe it would nice to have the same around the selBar...

@ValentinH
Copy link
Member

I manage to do it like this:

in the .less file:

rzslider span.rz-bar.rz-selection {
  //removed the width: 0%
  z-index: 1;
  background: @barFillColor;
  .rounded(@barHeight/2);
}

in the .js file, I wrapped the rz-selection span with a rz-bar-wrapper:

var template = '<span class="rz-bar-wrapper"><span class="rz-bar"></span></span>' + // 0 The slider bar
              '<span class="rz-bar-wrapper"><span class="rz-bar rz-selection"></span></span>' + // 1 Highlight between two handles
              '<span class="rz-pointer"></span>' + // 2 Left slider handle
              '<span class="rz-pointer"></span>' + // 3 Right slider handle
              '<span class="rz-bubble rz-limit"></span>' + // 4 Floor label
              '<span class="rz-bubble rz-limit"></span>' + // 5 Ceiling label
              '<span class="rz-bubble"></span>' + // 6 Label above left slider handle
              '<span class="rz-bubble"></span>' + // 7 Label above right slider handle
              '<span class="rz-bubble"></span>'; // 8 Range label when the slider handles are close ex. 15 - 17

Could you please try it and tell me what you think?

@ValentinH
Copy link
Member

Last but not least: don't forget to run the grunt task to generate the dist files. ;)

@coxm
Copy link
Contributor Author

coxm commented Aug 13, 2015

That was quick ^^.

I'll try it out now - and commit the dist files :)

@coxm
Copy link
Contributor Author

coxm commented Aug 13, 2015

Looks good to me! I'll commit it and include in the PR.

@ValentinH
Copy link
Member

There are conflictuels apparently... Can you rebase on top of the master? I pushed a commit yesterday. That might be the reason.

@coxm
Copy link
Contributor Author

coxm commented Aug 13, 2015

I think the conflicts may have appeared because of the dist file changes, but I'll rebase and check again.

@coxm
Copy link
Contributor Author

coxm commented Aug 13, 2015

Rebased!

@ValentinH
Copy link
Member

Actually, again about rebasing, can you rebase everything and merge all your commit into one?

@coxm
Copy link
Contributor Author

coxm commented Aug 19, 2015

OK, rebased and squashed! Sorry for the delay.

@ValentinH
Copy link
Member

Perfect!

ValentinH added a commit that referenced this pull request Aug 19, 2015
@ValentinH ValentinH merged commit 4a4f7d0 into angular-slider:master Aug 19, 2015
@coxm coxm deleted the draggable-bar branch August 20, 2015 09:17
@alanquigley
Copy link

This is a great feature, wondering if it would be possible to lock the range length?

@ValentinH
Copy link
Member

You mean that the user would not be able to drag a single toggle and only drag the whole range?

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.

3 participants