Skip to content

Commit 9433484

Browse files
committed
fix(range): show bubble when changing value
1 parent 94ac93f commit 9433484

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

docs/js/materialize.js

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/global.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Timepicker } from './timepicker';
2424
import { Toast } from './toasts';
2525
import { Tooltip } from './tooltip';
2626
import { Waves } from './waves';
27+
import { Range } from './range';
2728

2829
export class M {
2930
static version = '1.2.2';
@@ -117,6 +118,7 @@ export class M {
117118
Forms.Init();
118119
Chips.Init();
119120
Waves.Init();
121+
Range.Init();
120122
}
121123

122124
//--- TODO: Remove!
@@ -153,7 +155,6 @@ export class M {
153155
}
154156
//---
155157

156-
157158
static AutoInit(context:Element = null) {
158159
let root = !!context ? context : document.body;
159160
let registry = {
@@ -174,7 +175,7 @@ export class M {
174175
TapTarget: root.querySelectorAll('.tap-target:not(.no-autoinit)'),
175176
Timepicker: root.querySelectorAll('.timepicker:not(.no-autoinit)'),
176177
Tooltip: root.querySelectorAll('.tooltipped:not(.no-autoinit)'),
177-
FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
178+
FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)'),
178179
};
179180
M.Autocomplete.init(registry.Autocomplete, null);
180181
M.Carousel.init(registry.Carousel, null);
@@ -193,7 +194,7 @@ export class M {
193194
M.TapTarget.init(registry.TapTarget, null);
194195
M.Timepicker.init(registry.Timepicker, null);
195196
M.Tooltip.init(registry.Tooltip, null);
196-
M.FloatingActionButton.init(registry.FloatingActionButton, null);
197+
M.FloatingActionButton.init(registry.FloatingActionButton, null);
197198
}
198199

199200
static objectSelectorString(obj: any): string {

src/range.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,13 @@ const _defaults = {};
170170
_calcRangeOffset(): number {
171171
const width = this.el.getBoundingClientRect().width - 15;
172172
const max = parseFloat(this.el.getAttribute('max')) || 100; // Range default max
173-
const min = parseFloat(this.el.getAttribute('min')) || 0; // Range default min
174-
const percent = (parseFloat(this.el.getAttribute('value')) - min) / (max - min);
173+
const min = parseFloat(this.el.getAttribute('min')) || 0; // Range default min
174+
const percent = (parseFloat(this.el.value) - min) / (max - min);
175175
return percent * width;
176176
}
177+
178+
static Init(){
179+
Range.init(document.querySelectorAll('input[type=range]'), {});
180+
}
177181
}
178182

0 commit comments

Comments
 (0)