Skip to content

Commit

Permalink
feat: add clip option
Browse files Browse the repository at this point in the history
I am adding "clip" so that creating the bleeding edge on both sides of
the gallery is easier to do. Without it, one would have to configure
something like 3.2 items visible and that to me looks messy.
  • Loading branch information
daelmaak committed Sep 4, 2023
1 parent 8aa1545 commit 5ff8a5e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
[errorText]="errorText"
[mouseGestures]="mouseGestures"
[touchGestures]="touchGestures"
[clip]="clip"
[counter]="counter"
[counterOrientation]="counterOrientation"
[visibleItems]="visibleItems"
Expand Down
6 changes: 6 additions & 0 deletions libs/gallery/src/lib/components/gallery/gallery.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export class GalleryComponent {
@Input() errorText: string;
@Input() mouseGestures = true;
@Input() touchGestures = true;
/**
* Controls whether items outside gallery's scrollport should overflow it. When clip == false,
* items overflowing the gallery will be visible on both sides. Otherwise they will be hidden
* with `overflow: hidden`.
*/
@Input() clip = true;
@Input() counter = true;
@Input() counterOrientation: VerticalOrientation = 'bottom';
@Input() visibleItems = 1;
Expand Down
5 changes: 4 additions & 1 deletion libs/gallery/src/lib/components/viewer/viewer.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
outline: none;
// NOTE on z-index: It prevents creation of secondary layer for scrollable content (found out in Chromium dev tools in Layers) in context of the viewer DOM element.
// This secondary layer holds a large portion of memory
// Positive z-index prevent creation of this layer. It also causes a separate layer to be created, because it has "composited" descendants - ul element,
// however, this layer holds much less memory.
z-index: 1;

&.clip {
overflow: hidden;
}

&.rtl {
.viewer-arrow-next {
right: auto;
Expand Down
4 changes: 4 additions & 0 deletions libs/gallery/src/lib/components/viewer/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export class ViewerComponent implements OnChanges, OnInit, AfterViewInit {
@Input() visibleItems: number;
@Input() moveByItems: number;

@HostBinding('class.clip')
@Input()
clip: boolean;

@HostBinding('class.rtl')
@Input()
isRtl: boolean;
Expand Down

0 comments on commit 5ff8a5e

Please sign in to comment.