-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Slider: bugfix and improving implements #4678
Conversation
…dating when opening Chrome DevTools
…) and settings.onMove()
: | ||
module.is.reversed() ? 'right' : 'left' | ||
$label = $('<li class="label">' + module.get.label(i) + '</li>'), | ||
ratio = i / (len + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't quite right. If I have a max of 10 and a min of 0, I am going to have 8 labels. So this would be 1/9
not 1/10
as it should be.
With the change to module.get.numLables()
: i / (len + 1)
-> i / len
$labels = $module.append('<ul class="auto labels"></ul>').find('.labels'); | ||
for(var i = 0; i <= module.get.numLabels(); i++) { | ||
} | ||
for(var i = 1, len = module.get.numLabels(); i <= len; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i <= len
-> i < len
to go along with the change in module.get.numLables()
:
var value = Math.round((module.get.max() - module.get.min()) / module.get.step()) - 2;
should now be
var value = Math.round((module.get.max() - module.get.min()) / module.get.step());
; | ||
$children.each(function(index) { | ||
var | ||
$child = $(this), | ||
$child = $(this), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need for more whitespace
@gdaunton Thanks, all known issues are already fixed. :) |
Really love the calc solution on this 👍 . I think it is a tiny bit slower, but it does get rid of the positioning issues when the slider width changes. Thanks for the help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things that need to be removed thanks to the awesome calc
solution. Other then that LGTM! 🎉
@@ -122,7 +122,7 @@ $.fn.slider = function(parameters) { | |||
module.unbind.events(); | |||
module.unbind.slidingEvents(); | |||
$module.removeData(moduleNamespace); | |||
module.disconnect.sliderObserver(); | |||
// module.disconnect.sliderObserver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go ahead and remove this line and function if it is no longer used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you can probably remove the resize listener
@@ -244,7 +243,7 @@ $.fn.slider = function(parameters) { | |||
bind: { | |||
events: function() { | |||
module.bind.globalKeyboardEvents(); | |||
module.bind.resizeListener(); | |||
// module.bind.resizeListener(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔪
@@ -309,7 +308,7 @@ $.fn.slider = function(parameters) { | |||
$module.off('touchstart' + eventNamespace); | |||
$module.off('keydown' + eventNamespace); | |||
$module.off('focusout' + eventNamespace); | |||
$(window).off('resize' + eventNamespace); | |||
// $(window).off('resize' + eventNamespace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔪
@@ -103,9 +103,9 @@ $.fn.slider = function(parameters) { | |||
module.read.metadata(); | |||
module.read.settings(); | |||
|
|||
module.observeChanges(); | |||
// module.observeChanges(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔪
@@ -138,6 +138,9 @@ $.fn.slider = function(parameters) { | |||
slider: function() { | |||
sliderObserver.observe($module[0], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to have an observer? I can't think of anything in the class or style that would change where we would need to re-sync everything as all the positioning is percentage based.
transform: translateX(-50%); | ||
} | ||
|
||
.ui.labeled.vertical.slider > .labels .label { | ||
transform: translate(-100%, -@labelWidth); | ||
transform: translate(-100%, -50%); // translate(-100%, -@labelWidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can 🔪 the comment
@gdaunton The commented codes are all removed. And, I create a demo which can be used to test new changes. The issue you mentioned should already be fixed in previous submits :) |
There are following changes:
calc()
to locate thumb, track fill and labels, so no need to listen resize event or observe element changes;thumbVal
,secondThumbVal
for listeneronChange()
andonMove()
;value
,module.thumbVal
,module.secondThumbVal
,position
andsecondPos
;value
tomin
ormax
when mouse is moving out slider;