Skip to content

fix(plugin-block): fix mouse move debouncing does not work #1271

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

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

syfxlin
Copy link
Contributor

@syfxlin syfxlin commented Mar 18, 2024

  • I read the contributing guide
  • I agree to follow the code of conduct

Summary

The lodash.debounce function creates a wrapped function, and if you recreate the wrapped function each time, debounce will not take effect.

The following sample code briefly explains how it works, you can see that the timerId is saved in the context of the debounce function, you need to save it to achieve the debounce effect, if you call the lodash.debounce function every time, it will always be the initial value.

function debounce(fn, wait = 500) {
  let timerId;
  return (...args) => {
    clearTimeout(timerId);
    timerId = setTimeout(() => {
      fn(...args);
    }, wait);
  };
}

How did you test this change?

before

You can see that the buttons on the left side of the mouse are constantly jumping when you move the mouse, and debounce has no effect.

before

after

after

Copy link

vercel bot commented Mar 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
milkdown-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 18, 2024 4:13pm

Copy link

nx-cloud bot commented Mar 21, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 08b4e8f. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 3 targets

Sent with 💌 from NxCloud.

@Saul-Mirone Saul-Mirone merged commit d79c1d1 into Milkdown:main Mar 21, 2024
12 checks passed
Copy link

cypress bot commented Mar 21, 2024

Passing run #738 ↗︎

0 83 0 0 Flakiness 0

Details:

fix(plugin-block): fix mouse move debouncing does not work (#1271)
Project: Default Project Commit: d79c1d179c
Status: Passed Duration: 01:52 💡
Started: Mar 21, 2024 7:59 AM Ended: Mar 21, 2024 8:01 AM

Review all test suite changes for PR #1271 ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants