Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Do not calculate position on hidden elements #149

Closed
wants to merge 2 commits into from

Conversation

coderjp
Copy link

@coderjp coderjp commented May 13, 2015

If an slider is hidden on init, it will always set its min attribute as its value. This overwrites any default value that is set via the value attribute.

This commit will prevent a hidden element from calculating its position and instead rely on the defaults set.

This will also prevent any the onSlide and onSlideEnd callbacks from being run on a hidden element - however if it's hidden, these wouldn't be trigger-able anyway!

If an slider is hidden on init, it will always set its min attribute as its value. This overwrites any default value that is set via the value attribute.

This commit will prevent a hidden element from calculating its position and instead rely on the defaults set. 

This will also prevent any the onSlide and onSlideEnd callbacks from being run on a hidden element - however if it's hidden, these wouldn't be trigger-able anyway!
@andreruffert
Copy link
Owner

First of all thanks for your pr maybe I misunderstood you but I don't get your point.
Check this example it works fine for me.
The input[type="range"] is hidden on initialization and sets the correct attributes.

The problem is if you show the hidden element later somehow and don't calculating it's position etc. the UI of the slider is not correct and that's what you probably expect if it was initialized.

@coderjp
Copy link
Author

coderjp commented May 15, 2015

After further testing it only happens when an !important is on the hidden class as can be seen here:
http://codepen.io/anon/pen/YXqbvK

As the website I am using it on uses Bootstrap, hide and hidden both have !important in their classes. It looks like the "display: none !important" is overwriting the rangeslider classes

@boekkooi
Copy link
Contributor

@coderjp Why not use .is(':hidden')

@ge0ffray
Copy link
Contributor

Hello, I just sent a PR correcting this problem : #188

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

Successfully merging this pull request may close these issues.

4 participants