aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorMehek Jethani <53710923+mehekj@users.noreply.github.com>2022-03-20 22:46:09 -0400
committerGitHub <noreply@github.com>2022-03-20 22:46:09 -0400
commit0885f2b6ea10bdc54f587040ea8e6dc90ef5b0f3 (patch)
tree7d10a6a48e93b16cd1c8a4b285ec022f5b515738 /src/Utils.ts
parent5d50e0673fde8aabb2d87a75624b40d3b9c65df3 (diff)
parent39c85293f6c3d385ea64ba0db8c9736dfaaec993 (diff)
Merge pull request #43 from brown-dash/temporalmedia-mehek
Temporalmedia mehek - audio and video UI updates. adds trimming, zooming, and volume controls. replaces native video controls with dash UI
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index f2d9e7766..5f46ef5c9 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -514,6 +514,26 @@ export function smoothScroll(duration: number, element: HTMLElement | HTMLElemen
};
animateScroll();
}
+
+export function smoothScrollHorizontal(duration: number, element: HTMLElement | HTMLElement[], to: number) {
+ const elements = (element instanceof HTMLElement ? [element] : element);
+ const starts = elements.map(element => element.scrollLeft);
+ const startDate = new Date().getTime();
+
+ const animateScroll = () => {
+ const currentDate = new Date().getTime();
+ const currentTime = currentDate - startDate;
+ elements.map((element, i) => element.scrollLeft = easeInOutQuad(currentTime, starts[i], to - starts[i], duration));
+
+ if (currentTime < duration) {
+ requestAnimationFrame(animateScroll);
+ } else {
+ elements.forEach(element => element.scrollLeft = to);
+ }
+ };
+ animateScroll();
+}
+
export function addStyleSheet(styleType: string = "text/css") {
const style = document.createElement("style");
style.type = styleType;