Skip to content

Commit ccd926b

Browse files
manucorporatadamdbradley
authored andcommitted
feat(range): range can be disabled
1 parent af289ec commit ccd926b

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

src/components/range/range.ios.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $range-ios-slider-height: 42px !default;
1212
$range-ios-hit-width: 42px !default;
1313
$range-ios-hit-height: $range-ios-slider-height !default;
1414

15-
$range-ios-bar-height: 1px !default;
15+
$range-ios-bar-height: 2px !default;
1616
$range-ios-bar-background-color: #bdbdbd !default;
1717
$range-ios-bar-active-background-color: color($colors-ios, primary) !default;
1818

@@ -67,6 +67,8 @@ ion-range {
6767
width: 100%;
6868
height: $range-ios-bar-height;
6969

70+
border-radius: 1px;
71+
7072
background: $range-ios-bar-background-color;
7173

7274
pointer-events: none;
@@ -166,6 +168,11 @@ ion-range {
166168
transform: translate3d(0, 0, 0) scale(1);
167169
}
168170

171+
.range-disabled {
172+
opacity: 0.5;
173+
}
174+
175+
169176
// Generate iOS Range Colors
170177
// --------------------------------------------------
171178

src/components/range/range.md.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,19 @@ ion-range:not(.range-has-pin) .range-knob-pressed .range-knob {
220220

221221
@include md-range-min();
222222

223+
.range-disabled {
224+
.range-bar-active {
225+
background-color: $range-md-bar-background-color;
226+
}
227+
228+
.range-knob {
229+
transform: scale(.55);
230+
background-color: $range-md-bar-background-color;
231+
outline: 5px solid white;
232+
}
233+
234+
}
235+
223236

224237
// Generate Material Design Range Colors
225238
// --------------------------------------------------

src/components/range/range.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ export class Range {
356356
* @private
357357
*/
358358
pointerDown(ev: UIEvent) {
359+
// TODO: we could stop listening for events instead of checking this._disabled.
360+
// since there are a lot of events involved, this solution is
361+
// enough for the moment
362+
if (this._disabled) {
363+
return;
364+
}
359365
console.debug(`range, ${ev.type}`);
360366

361367
// prevent default so scrolling does not happen

src/components/range/test/basic/page1.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
</ion-range>
4444
</ion-item>
4545

46+
<ion-item>
47+
<ion-label>disabled</ion-label>
48+
<ion-range min="20" max="80" step="2" [(ngModel)]="singleValue3" disabled=true>
49+
<ion-icon small range-left name="sunny"></ion-icon>
50+
<ion-icon range-right name="sunny"></ion-icon>
51+
</ion-range>
52+
</ion-item>
53+
4654
<ion-item>
4755
<ion-label>step=100, snaps, {{singleValue4}}</ion-label>
4856
<ion-range min="1000" max="2000" step="100" snaps="true" secondary [(ngModel)]="singleValue4"></ion-range>

0 commit comments

Comments
 (0)