Skip to content

Commit

Permalink
fix debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuiantw1212 committed May 13, 2024
1 parent ff76138 commit da55af7
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion components/calculator/career/government.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ function tooltipFormat(tooltipItems) {
}
const debounceId = ref()
function debounce(func, delay = 100) {
function debounce(func, delay = 250) {
return (immediate) => {
clearTimeout(debounceId.value)
if (immediate) {
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/career/labor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ const errorMssage = throttle(() => {


const debounceId = ref()
function debounce(func, delay = 100) {
function debounce(func, delay = 250) {
return (immediate) => {
clearTimeout(debounceId.value)
if (immediate) {
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/estate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function drawDownpayChart() {
debounceId.value = undefined
downPayChartInstance.value.data = chartData
downPayChartInstance.value.update()
}, 150)
}, 250)
} else {
const ctx: any = document.getElementById('savingDownpayChart')
const chartInstance = new Chart(ctx, {
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/parenting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function showChildExpense(tooltipItems) {
}
const debounceId = ref()
function debounce(func, delay = 150) {
function debounce(func, delay = 250) {
return (immediate) => {
clearTimeout(debounceId.value)
if (immediate) {
Expand Down
12 changes: 0 additions & 12 deletions components/calculator/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,7 @@ async function drawProfileChart(propagate = false) {
if (yearOfBirth && gender) {
const ceYear = new Date().getFullYear()
const calculateAge = ceYear - Number(yearOfBirth)
// const res = await fetch(`${VITE_BASE_URL}/calculate/lifeExpectancy`, {
// method: 'post',
// body: JSON.stringify({
// ceYear,
// age: calculateAge,
// gender,
// }),
// headers: { 'Content-Type': 'application/json' }
// })
// const lifeExpectancy = await res.json()
profile.value.age = calculateAge
// profile.value.lifeExpectancy = Number(lifeExpectancy)
// profile.value.longevity = calculateAge + lifeExpectancy
if (propagate) {
emits('update:modelValue', profile.value)
}
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/report/lifeAsset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function drawLifeAsset(payload) {
}
const debounceId = ref()
function customDebounce(func, delay = 100) {
function customDebounce(func, delay = 250) {
return (immediate) => {
clearTimeout(debounceId.value)
if (immediate) {
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/retirement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ async function drawRetirementAssetChart() {
debounceId.value = setTimeout(() => {
pensionChartInstance.value.data = chartData
pensionChartInstance.value.update()
}, 150)
}, 250)
} else {
const ctx: any = document.getElementById('pensionChart')
const chartInstance = new Chart(ctx, {
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/security.vue
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function drawLifeAssetChart() {
debounceId.value = undefined
securityChartInstance.value.data = chartData
securityChartInstance.value.update()
}, 150)
}, 250)
} else {
const ctx: any = document.getElementById('securityChart')
const chartInstance = new Chart(ctx, {
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/spouse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function drawMarriageChart(propagate = true) {
}
const debounceId = ref()
function debounce(func, delay = 150) {
function debounce(func, delay = 250) {
return (immediate) => {
clearTimeout(debounceId.value)
if (immediate) {
Expand Down

0 comments on commit da55af7

Please sign in to comment.