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

Feat: Range slider with float step size #6812

Closed
basvdijk opened this issue Jun 8, 2016 · 16 comments
Closed

Feat: Range slider with float step size #6812

basvdijk opened this issue Jun 8, 2016 · 16 comments
Assignees

Comments

@basvdijk
Copy link

basvdijk commented Jun 8, 2016

The new range slider is awesome. I am using it to quickly rate objects. It looks like is not possible to set the step value to a float. For a rating value between 1 and 10 it would be great to set the step value at 0.5.

@manucorporat
Copy link
Contributor

manucorporat commented Jun 8, 2016

I agree with you, in the mean time, as a workaround, you could just use a wider range, let's say between 0 and 1000 and then divide the step by 1000. so you have a float step size of 0.001.

@manucorporat manucorporat self-assigned this Jun 8, 2016
@adamdbradley
Copy link
Contributor

Yeah good call. I used Math.round() everywhere to prevent crazy awesome JavaScript 6.9999999998 numbers, but it should have a smarter method to both clean up the number, and also allow for decimals.

@basvdijk
Copy link
Author

basvdijk commented Jun 9, 2016

👍 Great! Thanks for looking into this!

@PAFsec
Copy link

PAFsec commented Nov 7, 2016

Hi !

Where is the state of that enhancement ? Is it going to be included in RC3 ?

On my side, I temporarely edited the component node_modules/ionic-angular/components/range.js, and more specificaly the function Range.prototype.ratioToValue at the lines 372 and 373, and put instead :

        ratio = (((this._max - this._min) * ratio)).toFixed(1);
        ratio = ((ratio / this._step) * this._step + this._min).toFixed(1);     

You can change 1 by the number of decimals you want.

On that note there should be a decimal option in which by default gives you 0 decimal, but can be manually changed.

Have a great day.

@manucorporat
Copy link
Contributor

@PAFsec right now ionic 2 is feature frozen, until 2.0 final is released.
do you have any proposal about how this should be implemented and/or which API should we provide?

@PAFsec
Copy link

PAFsec commented Nov 7, 2016

I think an optional input property called "decimal" (like the already existing one max, main) that would let the developper decide how many decimals he/she wants to have (defaulted to the value "0") should be sufficient.

What do you think ?

@manucorporat
Copy link
Contributor

I like it, simple, easy, powerful and back compatible.

how about resolution?

@PAFsec
Copy link

PAFsec commented Nov 7, 2016

For the name of the input ?
I honnestly am OK for whatever name :)

@manucorporat
Copy link
Contributor

@PAFsec could you try to submit a PR? I would review it

@PAFsec
Copy link

PAFsec commented Nov 7, 2016

Why not !
I will try to do that. I will keep you posted !

@jgw96
Copy link
Contributor

jgw96 commented Feb 7, 2017

Hello everyone! Thanks for the feature request. I'm going to move this issue over to our internal list of feature requests for evaluation. We are continually prioritizing all requests that we receive with outstanding issues. We are extremely grateful for your feedback, but it may not always be our next priority. I'll copy the issue back to this repository when we have begun implementation. Thanks!

@jgw96
Copy link
Contributor

jgw96 commented Feb 7, 2017

This issue was moved to driftyco/ionic-feature-requests#110

@jgw96 jgw96 closed this as completed Feb 7, 2017
@PAFsec
Copy link

PAFsec commented Jun 15, 2017

any news concerning that feature ?

@PAFsec
Copy link

PAFsec commented Jun 29, 2017

With recent release, the temporary workaround does not properly work anymore.
Indeed, it is possible to observe some shaky behaviour of the slider/knob.

Does anyone have suggestions ?

@viki53
Copy link

viki53 commented Aug 14, 2017

Any news on this feature? Can the issue be re-opened?

Native browser range inputs handle this behavior, Ionic should at least provide the same level of functionalities…


I'm having the same issue and the workaround is not an option when using the pin option as the shown value would not be the one the user expects.

If it helps, I'm trying to do something a little excentric: a 0-20 slider with steps of 1, which turns into a 0-2 range with 0.25 steps when the value is under 2.

My current code looks like this:

<ion-item no-lines *ngIf="quantity < 2">
	<ion-range min="0" max="2" step="0.25" snaps="true" pin="true" [(ngModel)]="quantity">
		<ion-label range-left>0</ion-label>
		<ion-label range-right>2</ion-label>
	</ion-range>
</ion-item>
<ion-item no-lines *ngIf="quantity >= 2">
	<ion-range min="0" max="20" step="1" snaps="true" pin="true" [(ngModel)]="quantity">
		<ion-label range-left>0</ion-label>
		<ion-label range-right>20</ion-label>
	</ion-range>
</ion-item>

Also tried this before (similar result):

<ion-item no-lines>
	<ion-range min="0" [max]="quantity < 2 ? 2 : 20" [step]="quantity < 2 ? 0.25 : 1" snaps="true" pin="true" [(ngModel)]="quantity">
		<ion-label range-left>0</ion-label>
		<ion-label range-right>{{ quantity < 2 ? 2 : 20 }}</ion-label>
	</ion-range>
</ion-item>

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 2, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 2, 2018
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 a pull request may close this issue.

7 participants