Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8cab1fd

Browse files
authoredApr 26, 2021
Slider bar width and knob size increases (#170)
* increase slider width * slider knob size
1 parent 8f681e9 commit 8cab1fd

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed
 

‎examples/slider.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313

1414
wired-slider {
15-
margin: 5px 0;
15+
margin: 16px 0;
1616
max-width: 100%;
1717
box-sizing: border-box;
1818
}
@@ -27,9 +27,13 @@
2727

2828
<body>
2929
<wired-slider></wired-slider>
30-
<wired-slider value="40"></wired-slider>
30+
<br>
31+
<wired-slider value="40" style="width: 600px;"></wired-slider>
32+
<br>
3133
<wired-slider value="10" min="5" max="15"></wired-slider>
34+
<br>
3235
<wired-slider value="60" disabled></wired-slider>
36+
<br>
3337
<wired-slider class="custom" value="25"></wired-slider>
3438
</body>
3539

‎src/wired-slider.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class WiredSlider extends WiredBase {
6363
cursor: pointer;
6464
border: none;
6565
margin: 0;
66-
height: 20px;
67-
width: 20px;
66+
height: 24px;
67+
width: 24px;
6868
line-height: 1;
6969
}
7070
input[type=range]::-webkit-slider-thumb {
@@ -73,8 +73,8 @@ export class WiredSlider extends WiredBase {
7373
background: none;
7474
cursor: pointer;
7575
border: none;
76-
height: 20px;
77-
width: 20px;
76+
height: 24px;
77+
width: 24px;
7878
margin: 0;
7979
line-height: 1;
8080
}
@@ -84,6 +84,7 @@ export class WiredSlider extends WiredBase {
8484
}
8585
.bar {
8686
stroke: var(--wired-slider-bar-color, rgb(0, 0, 0));
87+
stroke-width: 1;
8788
}
8889
input:focus + div svg .knob {
8990
stroke: var(--wired-slider-knob-outline-color, #000);
@@ -161,7 +162,7 @@ export class WiredSlider extends WiredBase {
161162
this.canvasWidth = size[0];
162163
const midY = Math.round(size[1] / 2);
163164
line(svg, 0, midY, size[0], midY, this.seed).classList.add('bar');
164-
this.knob = ellipse(svg, 10, midY, 20, 20, this.seed);
165+
this.knob = ellipse(svg, 12, midY, 24, 24, this.seed);
165166
this.knob.classList.add('knob');
166167
}
167168

@@ -171,7 +172,7 @@ export class WiredSlider extends WiredBase {
171172
const delta = Math.max(this.step, this.max - this.min);
172173
const pct = (value - this.min) / delta;
173174
if (this.knob) {
174-
this.knob.style.transform = `translateX(${pct * (this.canvasWidth - 20)}px)`;
175+
this.knob.style.transform = `translateX(${pct * (this.canvasWidth - 24)}px)`;
175176
}
176177
}
177178
}

0 commit comments

Comments
 (0)
Please sign in to comment.