Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1936] Migrate c-resizer.vue to typescript #2038

Merged
merged 6 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) => {
jq1836 marked this conversation as resolved.
Show resolved Hide resolved
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>
Loading