-
Notifications
You must be signed in to change notification settings - Fork 195
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
Update range display #165
Update range display #165
Conversation
This is weird. UT were passing in Firefox... |
At last :) Travis/PhantomJS doesn't seem to like |
Thank you, this is a great new feature ! Why did you force the installation of phantomJS 2.0.0 for unit testing ? |
@@ -219,6 +219,11 @@ | |||
self.onUpdateEvent(e, opt); | |||
}); | |||
|
|||
// Attach showElementsInRange event | |||
self.$container.on("showElementsInRange." + pluginName, function (e, ranges) { |
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.
Does the argument ranges
shouldn't be called options
because we can set options like hiddenOpacity or animDuration in this object ?
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.
Right! It was from an earlier version where I only passed a ranged array. I forgot to update this part after extending the event.
I commited the new names. |
var range = ranges[valueIndex]; | ||
// Check if user defined at least a min or max value | ||
if (range.min === undefined && range.max === undefined) { | ||
return true; // next range |
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.
As the function is not expected to return any value, maybe we should just do return;
here ?
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.
Actually, no. This return true;
is related to the $.each()
function callback.
Returning true will go to the next item (like a continue
statement). Whereas false will end the loop (much like a break
statement). See jQuery doc: http://api.jquery.com/jQuery.each/
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 are right, thank you !
elem.mapElem.attr({"opacity": opacity}); | ||
// For extrem opacity, hide or show | ||
if (opacity === 0) elem.mapElem.hide(); | ||
else if (opacity === 1) elem.mapElem.show(); |
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.
Seems to be redundent with L761 elem.mapElem.show();
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.
Fixed :)
self.setElementOpacity( | ||
elem, | ||
(elem.mapElem.originalAttrs.opacity !== undefined) ? elem.mapElem.originalAttrs.opacity : 1, | ||
animDuration |
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.
Maybe the 'animDuration' should be added to the arguments of fnShowElement() ?
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.
Why? It is available in the parent onUpdateEvent()
function as a closure.
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.
My bad, you are right !
Implements #110 second option!
Usage:
Provided are 2 advanced examples using NoUISlider (http://refreshless.com/nouislider).
As a nice effect, I factorized some function using the new
setElementOpacity()
function.