libs/upp-wdgt/src/components/upp-scrollable/upp-scrollable.ts
A reusable scrollable component for Angular applications.
This component provides a customizable scroll behavior for its content, with the ability
to configure scroll directions (x, y, both, or none). It leverages HostBinding to
dynamically set CSS classes based on the input properties and the state of the viewService.
<upp-scrollable scrollbar="x">
<div>Scrollable content here</div>
</upp-scrollable>viewService for additional view-specific adjustments.| selector | upp-scrollable |
| styleUrls | ./upp-scrollable.scss |
| templateUrl | ./upp-scrollable.html |
Properties |
|
Inputs |
HostBindings |
Accessors |
constructor(view: viewService)
|
||||||||
|
Constructor for the UppScrollableComponent. Example :
Parameters :
|
| class |
Type : string
|
|
Dynamically generates CSS classes based on the
|
| Public view |
Type : viewService
|
|
A service providing view-related state, such as whether the current view
is on a mobile device or has a visible scrollbar.
|
| panelClasses |
getpanelClasses()
|
|
Dynamically generates CSS classes based on the
Returns :
string
|
<div class="wrapper">
<div class="upp-scrollable-content" [ngClass]="{ 'mobile': view.Mobile, 'show': view.Scrollbar }">
<div style="clear: both; height: 100%;">
<ng-content></ng-content>
<div style="clear: both; height: 200px"></div>
</div>
</div>
</div>
./upp-scrollable.scss
:host {
display: block;
width: 100%;
height: 100%;
overflow: hidden;
.wrapper {
display: flex;
flex-direction: column;
position: relative;
width: 100%;
height: 100%;
}
.upp-scrollable-content {
flex-grow: 1;
width: 100%;
height: 100%;
overflow: auto;
}
&.--no-scrollbar-y .upp-scrollable-content {
box-sizing: content-box;
background: var(--ion-background-color);
scrollbar-width: none;
height: 100%;
&.show {
overflow-y: auto !important;
margin: 0px !important;
padding: 0px !important;
&::-webkit-scrollbar {
width: 10px !important;
}
&::-webkit-scrollbar-track {
background-color: var(--ion-background-color);
}
&::-webkit-scrollbar-thumb {
background-color: var(--ion-color-medium);
border-radius: 5px;
}
}
// https://www.geeksforgeeks.org/hide-scroll-bar-but-while-still-being-able-to-scroll-using-css/
overflow-y: -moz-scrollbars-none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
width: 0 !important
}
margin: 0px -30px 0px 0px;
padding: 0px 30px 0px 0px;
z-index: 0;
&.mobile { /* adjust for mobile devices */
width: 100%;
overflow-y: auto;
margin-right: 0px;
padding: 0px !important;
}
}
&.--no-scrollbar-x .upp-scrollable-content {
box-sizing: content-box;
background: var(--ion-background-color);
scrollbar-width: none;
width: 100%;
&.show {
overflow-x: auto !important;
margin: 0px !important;
padding: 0px !important;
&::-webkit-scrollbar {
width: 10px !important;
}
&::-webkit-scrollbar-track {
background-color: var(--ion-background-color);
}
&::-webkit-scrollbar-thumb {
background-color: var(--ion-color-medium);
border-radius: 5px;
}
}
// https://www.geeksforgeeks.org/hide-scroll-bar-but-while-still-being-able-to-scroll-using-css/
overflow-x: -moz-scrollbars-none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
width: 0 !important
}
z-index: 0;
&.mobile { /* adjust for mobile devices */
width: 100%;
overflow-x: auto;
margin-right: 0px;
padding: 0px !important;
}
}
}