convert sensors to ts

This commit is contained in:
Laila Los
2022-12-06 15:41:04 +01:00
parent 4ae456b854
commit 47f41efd9b
4 changed files with 54 additions and 7 deletions
+1
View File
@@ -34,6 +34,7 @@
"@johmun/vue-tags-input": "^2.1.0",
"@popperjs/core": "^2.11.5",
"@sentry/browser": "^6.17.4",
"@vueuse/core": "^9.6.0",
"assert": "^2.0.0",
"axios": "^0.25.0",
"babel-runtime": "^6.26.0",
@@ -1,16 +1,28 @@
import { useAnimationFrame } from "./animationFrame";
import { unref } from "vue";
import type { MaybeComputedRef } from "@vueuse/core";
import { resolveUnref } from "@vueuse/core";
export function useAnimationFrameResizeObserver(element, callback) {
export type Size = { width: number; height: number };
type CallbackValue = { clientSize: Size; scrollSize: Size };
export type AnimationFrameResizeObserverCallback = (oldValue: CallbackValue, newValue: CallbackValue) => void;
export function useAnimationFrameResizeObserver(
element: MaybeComputedRef<HTMLElement | null>,
callback: AnimationFrameResizeObserverCallback
) {
var clientSize = { width: 0, height: 0 };
var scrollSize = { width: 0, height: 0 };
const isSameSize = (a, b) => {
const isSameSize = (a: Size, b: Size) => {
return a.width === b.width && a.height === b.height;
};
const { stop } = useAnimationFrame(() => {
const el = unref(element);
const el = resolveUnref(element);
if (!el) {
return;
}
const newClientSize = {
width: el.clientWidth,
@@ -1,7 +1,9 @@
import { useAnimationFrame } from "./animationFrame";
import { reactive, ref, unref } from "vue";
import { reactive, ref } from "vue";
import type { MaybeComputedRef } from "@vueuse/core";
import { resolveUnref } from "@vueuse/core";
export function useAnimationFrameScroll(element) {
export function useAnimationFrameScroll(element: MaybeComputedRef<HTMLElement | null>) {
const scrollLeft = ref(0);
const scrollTop = ref(0);
@@ -13,7 +15,12 @@ export function useAnimationFrameScroll(element) {
});
const { stop } = useAnimationFrame(() => {
const el = unref(element);
const el = resolveUnref(element);
if (!el) {
return;
}
const left = el.scrollLeft;
if (left !== scrollLeft.value) {
+27
View File
@@ -2062,6 +2062,11 @@
dependencies:
"@types/jest" "*"
"@types/web-bluetooth@^0.0.16":
version "0.0.16"
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.16.tgz#1d12873a8e49567371f2a75fe3e7f7edca6662d8"
integrity sha512-oh8q2Zc32S6gd/j50GowEjKLoOVOwHP/bWVjKJInBwQqdOYMdPrf1oVlelTlyfFK3CKxL1uahMDAr+vy8T7yMQ==
"@types/ws@^8.5.1":
version "8.5.3"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d"
@@ -2227,6 +2232,28 @@
source-map "0.5.6"
tsconfig "^7.0.0"
"@vueuse/core@^9.6.0":
version "9.6.0"
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-9.6.0.tgz#de1d4730849cdbe28a9ebcf6cad167a700919603"
integrity sha512-qGUcjKQXHgN+jqXEgpeZGoxdCbIDCdVPz3QiF1uyecVGbMuM63o96I1GjYx5zskKgRI0FKSNsVWM7rwrRMTf6A==
dependencies:
"@types/web-bluetooth" "^0.0.16"
"@vueuse/metadata" "9.6.0"
"@vueuse/shared" "9.6.0"
vue-demi "*"
"@vueuse/metadata@9.6.0":
version "9.6.0"
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-9.6.0.tgz#b0a73277538cebef5d477983f74fdd2aa21ce5f9"
integrity sha512-sIC8R+kWkIdpi5X2z2Gk8TRYzmczDwHRhEFfCu2P+XW2JdPoXrziqsGpDDsN7ykBx4ilwieS7JUIweVGhvZ93w==
"@vueuse/shared@9.6.0":
version "9.6.0"
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-9.6.0.tgz#ce2e0e8124c6bdb1e270fc213e334ccc71dcb951"
integrity sha512-/eDchxYYhkHnFyrb00t90UfjCx94kRHxc7J1GtBCqCG4HyPMX+krV9XJgVtWIsAMaxKVU4fC8NSUviG1JkwhUQ==
dependencies:
vue-demi "*"
"@webassemblyjs/ast@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"