Skip to content

Commit

Permalink
Migrate c-resizer to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jq1836 committed Sep 23, 2023
1 parent 3bad16b commit 9974ca1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions frontend/src/components/c-resizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
slot(name="right")
</template>

<script>
<script lang='ts'>
import { mapState } from 'vuex';
import { defineComponent } from 'vue';
const DRAG_BAR_WIDTH = 13.25;
const SCROLL_BAR_WIDTH = 17;
const GUIDE_BAR_WIDTH = 2;
const throttledEvent = (delay, handler) => {
const throttledEvent = (delay: number, handler: Function) => {
let lastCalled = 0;
return (...args) => {
return (event: MouseEvent) => {
if (Date.now() - lastCalled > delay) {
lastCalled = Date.now();
handler(...args);
handler(event);
}
};
};
export default {
export default defineComponent({
name: 'c-resizer',
data() {
Expand Down Expand Up @@ -68,7 +69,7 @@ export default {
mouseMove() {
if (this.isResizing) {
return throttledEvent(25, (event) => {
return throttledEvent(25, (event: MouseEvent) => {
this.guideWidth = (
Math.min(
Math.max(
Expand Down Expand Up @@ -102,5 +103,5 @@ export default {
this.$store.commit('updateTabState', false);
},
},
};
});
</script>

0 comments on commit 9974ca1

Please sign in to comment.