Skip to content

Commit

Permalink
Rename hook, var for debounce ms
Browse files Browse the repository at this point in the history
  • Loading branch information
Panagiotis Georgakopoulos committed Nov 29, 2020
1 parent 7e50e7c commit 7c597be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/components/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CellOutput } from "./CellOutput.js"
import { CellInput } from "./CellInput.js"
import { RunArea, useMillisSinceTruthy } from "./RunArea.js"
import { cl } from "../common/ClassTable.js"
import { useDropHandler } from "./dropHandler.js"
import { useDropHandler } from "./useDropHandler.js"

/**
* @typedef {Object} CodeState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useMemo } from "../imports/Preact.js"

const MAGIC_TIMEOUT = 500
const DEBOUNCE_MAGIC_MS = 250

const prepareFile = (file) =>
new Promise((resolve, reject) => {
Expand All @@ -17,7 +18,7 @@ const prepareFile = (file) =>
export const useDropHandler = (requests, on_change, cell_id) => {
const [savingFile, setSavingFile] = useState(false)
const [dragActive, setDragActiveFast] = useState(false)
const setDragActive = useMemo(() => _.debounce(setDragActiveFast, 200), [setDragActiveFast])
const setDragActive = useMemo(() => _.debounce(setDragActiveFast, DEBOUNCE_MAGIC_MS), [setDragActiveFast])
const inactiveHandler = useMemo(
() => (ev) => {
switch (ev.type) {
Expand Down

0 comments on commit 7c597be

Please sign in to comment.