Skip to content

Commit 68546c3

Browse files
authored
Increase touch target area of slider input (#3859)
1 parent 69188fe commit 68546c3

File tree

6 files changed

+90
-2
lines changed

6 files changed

+90
-2
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
* Closed #2956: Component authors can now prevent Shiny from creating an input binding on specific elements by adding the `data-shiny-no-bind-input` attribute to the element. The attribute may have any or no value; its presence will prevent binding. This feature is primarily useful for input component authors who want to use standard HTML input elements without causing Shiny to create an input binding for them. Additionally, Shiny now adds custom classes to its inputs. For example, `checkboxInput()` now has a `shiny-input-checkbox` class. These custom classes may be utilized in future updates to Shiny's input binding logic. (#3861)
1818

19+
* Slider inputs created with `sliderInput()` now have a larger target area for clicking or tapping on the slider line or the slider bar. (#3859)
20+
21+
1922
### Bug fixes
2023

2124
* Fixed #3771: Sometimes the error `ion.rangeSlider.min.js: i.stopPropagation is not a function` would appear in the JavaScript console. (#3772)

inst/www/shared/ionrangeslider/css/ion.rangeSlider.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@charset "UTF-8";
22
/* 'shiny' skin for Ion.RangeSlider, largely based on the 'big' skin, but with smaller dimensions, grayscale grid text, and without gradients
3+
© Posit, PBC, 2023
34
© RStudio, Inc, 2014
45
© Denis Ineshin, 2014 https://github.com/IonDen
56
© guybowden, 2014 https://github.com/guybowden
@@ -174,6 +175,18 @@
174175
background-color: #ededed;
175176
border: 1px solid #cccccc;
176177
border-radius: 8px;
178+
overflow: visible;
179+
}
180+
181+
.irs--shiny .irs-line::before {
182+
content: "";
183+
display: block;
184+
position: relative;
185+
cursor: s-resize;
186+
width: 100%;
187+
height: 22px;
188+
top: -9px;
189+
z-index: 1;
177190
}
178191

179192
.irs--shiny .irs-bar {
@@ -182,12 +195,24 @@
182195
border-top: 1px solid #428bca;
183196
border-bottom: 1px solid #428bca;
184197
background: #428bca;
198+
cursor: s-resize;
199+
z-index: 2;
185200
}
186201

187202
.irs--shiny .irs-bar--single {
188203
border-radius: 8px 0 0 8px;
189204
}
190205

206+
.irs--shiny .irs-bar::before {
207+
content: "";
208+
display: block;
209+
position: relative;
210+
width: 100%;
211+
height: 22px;
212+
top: -9px;
213+
z-index: 2;
214+
}
215+
191216
.irs--shiny .irs-shadow {
192217
top: 38px;
193218
height: 2px;
@@ -207,6 +232,7 @@
207232
background-color: #dedede;
208233
box-shadow: 1px 1px 3px rgba(255, 255, 255, 0.3);
209234
border-radius: 22px;
235+
z-index: 2;
210236
}
211237

212238
.irs--shiny .irs-handle.state_hover, .irs--shiny .irs-handle:hover {

inst/www/shared/ionrangeslider/scss/shiny.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* 'shiny' skin for Ion.RangeSlider, largely based on the 'big' skin, but with smaller dimensions, grayscale grid text, and without gradients
2+
© Posit, PBC, 2023
23
© RStudio, Inc, 2014
34
© Denis Ineshin, 2014 https://github.com/IonDen
45
© guybowden, 2014 https://github.com/guybowden
@@ -79,6 +80,19 @@ $font-family: $font-family-base !default;
7980
background-color: $line_bg_color;
8081
border: $line_border;
8182
@include border-radius-shim($line_height);
83+
84+
// Increase the touch target area of the slider line
85+
overflow: visible;
86+
&::before {
87+
content: "";
88+
display: block;
89+
position: relative;
90+
cursor: s-resize; // downward arrow
91+
width: 100%;
92+
height: $handle_height;
93+
top: -(($handle_height - $line_height / 2) / 2);
94+
z-index: 1; // raise touch area above grid
95+
}
8296
}
8397

8498
.#{$name}-bar {
@@ -87,10 +101,23 @@ $font-family: $font-family-base !default;
87101
border-top: 1px solid $bar_color;
88102
border-bottom: 1px solid $bar_color;
89103
background: $bar_color;
104+
cursor: s-resize; // downard arrow, overwritten when a range
105+
z-index: 2;
90106

91107
&--single {
92108
@include border-radius-shim($line_height 0 0 $line_height);
93109
}
110+
111+
// Increase the touch target area of the slider bar
112+
&::before {
113+
content: "";
114+
display: block;
115+
position: relative;
116+
width: 100%;
117+
height: $handle_height;
118+
top: -(($handle_height - $line_height / 2) / 2);
119+
z-index: 2; // raise touch area above line touch target
120+
}
94121
}
95122

96123
// sliderInput() doesn't currently support from_min/from_max, so this isn't relevant
@@ -114,6 +141,7 @@ $font-family: $font-family-base !default;
114141
background-color: $handle_color;
115142
box-shadow: $handle_box_shadow;
116143
border-radius: $handle_width;
144+
z-index: 2;
117145

118146
&.state_hover,
119147
&:hover {

inst/www/shared/shiny.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny_scss/shiny.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ pre.shiny-text-output {
157157
margin-top: -9px;
158158
}
159159
.slider-animate-button {
160+
/* Ensure controls above slider line touch target */
161+
position: relative;
162+
z-index: 1;
160163
opacity: 0.5;
161164
.pause {
162165
display: none;

tools/ion.rangeSlider-patches/0001-Add-skin-customized-for-Shiny.patch

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ new file mode 100644
33
index 00000000..ba052f8b
44
--- /dev/null
55
+++ b/inst/www/shared/ionrangeslider/scss/shiny.scss
6-
@@ -0,0 +1,173 @@
6+
@@ -0,0 +1,201 @@
77
+/* 'shiny' skin for Ion.RangeSlider, largely based on the 'big' skin, but with smaller dimensions, grayscale grid text, and without gradients
8+
+© Posit, PBC, 2023
89
+© RStudio, Inc, 2014
910
+© Denis Ineshin, 2014 https://github.com/IonDen
1011
+© guybowden, 2014 https://github.com/guybowden
@@ -85,6 +86,19 @@ index 00000000..ba052f8b
8586
+ background-color: $line_bg_color;
8687
+ border: $line_border;
8788
+ @include border-radius-shim($line_height);
89+
+
90+
+ // Increase the touch target area of the slider line
91+
+ overflow: visible;
92+
+ &::before {
93+
+ content: "";
94+
+ display: block;
95+
+ position: relative;
96+
+ cursor: s-resize; // downward arrow
97+
+ width: 100%;
98+
+ height: $handle_height;
99+
+ top: -(($handle_height - $line_height / 2) / 2);
100+
+ z-index: 1; // raise touch area above grid
101+
+ }
88102
+ }
89103
+
90104
+ .#{$name}-bar {
@@ -93,10 +107,23 @@ index 00000000..ba052f8b
93107
+ border-top: 1px solid $bar_color;
94108
+ border-bottom: 1px solid $bar_color;
95109
+ background: $bar_color;
110+
+ cursor: s-resize; // downard arrow, overwritten when a range
111+
+ z-index: 2;
96112
+
97113
+ &--single {
98114
+ @include border-radius-shim($line_height 0 0 $line_height);
99115
+ }
116+
+
117+
+ // Increase the touch target area of the slider bar
118+
+ &::before {
119+
+ content: "";
120+
+ display: block;
121+
+ position: relative;
122+
+ width: 100%;
123+
+ height: $handle_height;
124+
+ top: -(($handle_height - $line_height / 2) / 2);
125+
+ z-index: 2; // raise touch area above line touch target
126+
+ }
100127
+ }
101128
+
102129
+ // sliderInput() doesn't currently support from_min/from_max, so this isn't relevant
@@ -120,6 +147,7 @@ index 00000000..ba052f8b
120147
+ background-color: $handle_color;
121148
+ box-shadow: $handle_box_shadow;
122149
+ border-radius: $handle_width;
150+
+ z-index: 2;
123151
+
124152
+ &.state_hover,
125153
+ &:hover {

0 commit comments

Comments
 (0)