diff --git a/web/app/widget-wrappers/sticker-picker/sticker-picker.component.html b/web/app/widget-wrappers/sticker-picker/sticker-picker.component.html index efe1ad8..9d461af 100644 --- a/web/app/widget-wrappers/sticker-picker/sticker-picker.component.html +++ b/web/app/widget-wrappers/sticker-picker/sticker-picker.component.html @@ -14,7 +14,7 @@
-
+
{{ pack.displayName }}
+
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/web/app/widget-wrappers/sticker-picker/sticker-picker.component.scss b/web/app/widget-wrappers/sticker-picker/sticker-picker.component.scss index aec112a..6ccaaf2 100644 --- a/web/app/widget-wrappers/sticker-picker/sticker-picker.component.scss +++ b/web/app/widget-wrappers/sticker-picker/sticker-picker.component.scss @@ -43,6 +43,7 @@ .sticker-picker { margin: 15px 15px 30px; + padding-bottom: 40px; .sticker-pack { .header { @@ -92,5 +93,33 @@ } } } + + .sticker-pack-list { + position: fixed; + left: 0; + right: 0; + bottom: 0; + background-color: themed(stickerPickerControlBgColor); + border-top: 1px solid themed(stickerPickerShadowColor); + overflow-x: auto; + white-space: nowrap; + padding: 1px 15px; + + .sticker-pack-list-item { + display: inline-block; + cursor: pointer; + padding: 0 3px; + } + + .sticker-pack-list-config { + display: inline-block; + cursor: pointer; + height: 40px; + width: 40px; + padding: 3px; + text-align: center; + vertical-align: middle; + } + } } } \ No newline at end of file diff --git a/web/app/widget-wrappers/sticker-picker/sticker-picker.component.ts b/web/app/widget-wrappers/sticker-picker/sticker-picker.component.ts index 11f705d..c6dde11 100644 --- a/web/app/widget-wrappers/sticker-picker/sticker-picker.component.ts +++ b/web/app/widget-wrappers/sticker-picker/sticker-picker.component.ts @@ -1,6 +1,22 @@ +import { + animate, + state, + style, + transition, + trigger +} from '@angular/animations'; import { ChangeDetectorRef, Component, OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute } from "@angular/router"; import { CapableWidget, WIDGET_API_VERSION_OPENID } from "../capable-widget"; +import { fromEvent } from 'rxjs'; +import { + distinctUntilChanged, + filter, + map, + pairwise, + share, + throttleTime +} from 'rxjs/operators'; import { Subscription } from "rxjs/Subscription"; import { ScalarWidgetApi } from "../../shared/services/scalar/scalar-widget.api"; import { StickerApiService } from "../../shared/services/integrations/sticker-api.service"; @@ -14,10 +30,25 @@ import { WIDGET_STICKER_PICKER } from "../../shared/models/widget"; selector: "my-generic-widget-wrapper", templateUrl: "sticker-picker.component.html", styleUrls: ["sticker-picker.component.scss"], + animations: [ + trigger('hideList', [ + state( + 'hidden', + style({ opacity: 0, transform: 'translateY(100%)' }) + ), + state( + 'visible', + style({ opacity: 1, transform: 'translateY(0)' }) + ), + transition('* => *', animate('200ms ease-in')) + ]) + ] }) + export class StickerPickerWidgetWrapperComponent extends CapableWidget implements OnInit, OnDestroy { public isLoading = true; + public isListVisible = true; public authError = false; public packs: FE_UserStickerPack[]; @@ -68,6 +99,28 @@ export class StickerPickerWidgetWrapperComponent extends CapableWidget implement if (this.stickerWidgetApiSubscription) this.stickerWidgetApiSubscription.unsubscribe(); } + public ngAfterViewInit() { + const scroll$ = fromEvent(window, 'scroll').pipe( + throttleTime(10), + map(() => window.pageYOffset), + pairwise(), + map(([y1, y2]): string => (y2 < y1 ? 'up' : 'down')), + distinctUntilChanged(), + share() + ); + + const scrollUp$ = scroll$.pipe( + filter(direction => direction === 'up') + ); + + const scrollDown = scroll$.pipe( + filter(direction => direction === 'down') + ); + + scrollUp$.subscribe(() => (this.isListVisible = true)); + scrollDown.subscribe(() => (this.isListVisible = false)); + } + protected onSupportedVersionsFound(): void { super.onSupportedVersionsFound(); @@ -133,6 +186,16 @@ export class StickerPickerWidgetWrapperComponent extends CapableWidget implement } } + public scrollHorizontal(event: WheelEvent): void { + document.getElementsByClassName('sticker-pack-list')[0].scrollLeft += event.deltaY; + event.preventDefault(); + } + + public scrollToPack(id: string) { + const el = document.getElementById(id); + el.scrollIntoView({behavior: 'smooth'}); + } + public sendSticker(sticker: FE_Sticker, pack: FE_UserStickerPack) { ScalarWidgetApi.sendSticker(sticker, pack); }