Skip to content

Commit

Permalink
fix(dropdown): optional scrollhint on ios devices or firefox mobile
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lubber-de authored Sep 3, 2020
1 parent 7d48060 commit b10cf9d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/definitions/modules/dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,42 @@ select.ui.dropdown {
border: none !important;
box-shadow: none !important;
}
& when (@variationDropdownScrollhint) {
/* CSS specific to iOS devices or firefox mobile only */
@supports (-webkit-touch-callout: none) or (-webkit-overflow-scrolling: touch) or (-moz-appearance:none) {
@media (-moz-touch-enabled), (pointer: coarse) {
.ui.dropdown .scrollhint.menu:not(.hidden):before {
animation: scrollhint @scrollhintDuration @scrollhintEasing @scrollhintIteration;
content: '';
z-index: @scrollhintZIndex;
display: block;
position: absolute;
opacity: 0;
right: @scrollhintOffsetRight;
top: 0;
height: 100%;
border-right: @scrollhintRightBorder;
border-left: @scrollhintLeftBorder;
border-image: linear-gradient(to bottom, @scrollhintStartColor, @scrollhintEndColor) 1 100%;
}

.ui.inverted.dropdown .scrollhint.menu:not(.hidden):before {
border-image: linear-gradient(to bottom, @invertedScrollhintStartColor, @invertedScrollhintEndColor) 1 100%;
}

@keyframes scrollhint {
0% {
opacity: 1;
top: 100%;
}
100% {
opacity: 0;
top: 0;
}
}
}
}
}
}

& when (@variationDropdownSearch) {
Expand Down
1 change: 1 addition & 0 deletions src/themes/default/globals/variation.variables
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
@variationDropdownFluid: true;
@variationDropdownFloating: true;
@variationDropdownPointing: true;
@variationDropdownScrollhint: true;
@variationDropdownSizes: @variationAllSizes;

/* Embed */
Expand Down
15 changes: 15 additions & 0 deletions src/themes/default/modules/dropdown.variables
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@
@pointingUpwardMenuBorderRadius: @borderRadius;
@pointingUpwardArrowBoxShadow: @menuBorderWidth @menuBorderWidth 0 0 @menuBorderColor;

/* Scrollhint */
@scrollhintWidth: 0.25em;
@scrollhintRightBorder: @scrollhintWidth solid;
@scrollhintLeftBorder: 0;
@scrollhintZIndex: 15;
@scrollhintDuration: 2s;
@scrollhintEasing: @defaultEasing;
@scrollhintIteration: 2;
@scrollhintOffsetRight: @scrollhintWidth;
@scrollhintStartColor: rgba(0, 0, 0, 0.75);
@scrollhintEndColor: rgba(0, 0, 0, 0);

/*--------------
Inverted
Expand Down Expand Up @@ -451,3 +462,7 @@

@invertedLabelIconOpacity: 0.6;
@invertedLabelIconHoverOpacity: 0.8;

/* Scrollhint */
@invertedScrollhintStartColor: rgba(255, 255, 255, 0.75);
@invertedScrollhintEndColor: rgba(255, 255, 255, 0);

0 comments on commit b10cf9d

Please sign in to comment.