Skip to content

Commit b10cf9d

Browse files
authored
fix(dropdown): optional scrollhint on ios devices or firefox mobile
IOS devices do not show a scrollbar when the content is not scrolled. This is a design decision by apple and cannot be adjusted via CSS (for example by -webkit-scrollbar) A similiar behavior is built into firefox mobile (also on Android) That said if one opens a dropdown it is not clear, if the shown entries are the only available options or if the user has to scroll down to see more, which is confusing and probably leads to wrong selections (because the user did not know of more choices, because of avoided scrolling) This PR provides the optional scrollhint class to be used for the menu to show a short animation hint on the right edge (where the usual scrollbar appears) when the dropdown opens to indicate swiping to see more entries
1 parent 7d48060 commit b10cf9d

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

src/definitions/modules/dropdown.less

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,42 @@ select.ui.dropdown {
608608
border: none !important;
609609
box-shadow: none !important;
610610
}
611+
& when (@variationDropdownScrollhint) {
612+
/* CSS specific to iOS devices or firefox mobile only */
613+
@supports (-webkit-touch-callout: none) or (-webkit-overflow-scrolling: touch) or (-moz-appearance:none) {
614+
@media (-moz-touch-enabled), (pointer: coarse) {
615+
.ui.dropdown .scrollhint.menu:not(.hidden):before {
616+
animation: scrollhint @scrollhintDuration @scrollhintEasing @scrollhintIteration;
617+
content: '';
618+
z-index: @scrollhintZIndex;
619+
display: block;
620+
position: absolute;
621+
opacity: 0;
622+
right: @scrollhintOffsetRight;
623+
top: 0;
624+
height: 100%;
625+
border-right: @scrollhintRightBorder;
626+
border-left: @scrollhintLeftBorder;
627+
border-image: linear-gradient(to bottom, @scrollhintStartColor, @scrollhintEndColor) 1 100%;
628+
}
629+
630+
.ui.inverted.dropdown .scrollhint.menu:not(.hidden):before {
631+
border-image: linear-gradient(to bottom, @invertedScrollhintStartColor, @invertedScrollhintEndColor) 1 100%;
632+
}
633+
634+
@keyframes scrollhint {
635+
0% {
636+
opacity: 1;
637+
top: 100%;
638+
}
639+
100% {
640+
opacity: 0;
641+
top: 0;
642+
}
643+
}
644+
}
645+
}
646+
}
611647
}
612648

613649
& when (@variationDropdownSearch) {

src/themes/default/globals/variation.variables

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@
414414
@variationDropdownFluid: true;
415415
@variationDropdownFloating: true;
416416
@variationDropdownPointing: true;
417+
@variationDropdownScrollhint: true;
417418
@variationDropdownSizes: @variationAllSizes;
418419

419420
/* Embed */

src/themes/default/modules/dropdown.variables

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,17 @@
374374
@pointingUpwardMenuBorderRadius: @borderRadius;
375375
@pointingUpwardArrowBoxShadow: @menuBorderWidth @menuBorderWidth 0 0 @menuBorderColor;
376376

377+
/* Scrollhint */
378+
@scrollhintWidth: 0.25em;
379+
@scrollhintRightBorder: @scrollhintWidth solid;
380+
@scrollhintLeftBorder: 0;
381+
@scrollhintZIndex: 15;
382+
@scrollhintDuration: 2s;
383+
@scrollhintEasing: @defaultEasing;
384+
@scrollhintIteration: 2;
385+
@scrollhintOffsetRight: @scrollhintWidth;
386+
@scrollhintStartColor: rgba(0, 0, 0, 0.75);
387+
@scrollhintEndColor: rgba(0, 0, 0, 0);
377388

378389
/*--------------
379390
Inverted
@@ -451,3 +462,7 @@
451462

452463
@invertedLabelIconOpacity: 0.6;
453464
@invertedLabelIconHoverOpacity: 0.8;
465+
466+
/* Scrollhint */
467+
@invertedScrollhintStartColor: rgba(255, 255, 255, 0.75);
468+
@invertedScrollhintEndColor: rgba(255, 255, 255, 0);

0 commit comments

Comments
 (0)