fix debounce on safari

This commit is contained in:
Cassie Tarakajian 2016-10-19 13:29:02 -04:00
parent a4b6dd194e
commit 0ccfeb6b9c
2 changed files with 7 additions and 7 deletions

View File

@ -27,7 +27,7 @@ import InlineSVG from 'react-inlinesvg';
const downArrowUrl = require('../../../images/down-arrow.svg'); const downArrowUrl = require('../../../images/down-arrow.svg');
import classNames from 'classnames'; import classNames from 'classnames';
import { debounce } from 'throttle-debounce'; import { debounce } from 'lodash';
class Editor extends React.Component { class Editor extends React.Component {
constructor(props) { constructor(props) {
@ -49,7 +49,7 @@ class Editor extends React.Component {
gutters: ['CodeMirror-lint-markers'], gutters: ['CodeMirror-lint-markers'],
keyMap: 'sublime', keyMap: 'sublime',
lint: { lint: {
onUpdateLinting: debounce(2000, (annotations) => { onUpdateLinting: debounce((annotations) => {
this.props.clearLintMessage(); this.props.clearLintMessage();
annotations.forEach((x) => { annotations.forEach((x) => {
if (x.from.line > -1) { if (x.from.line > -1) {
@ -59,17 +59,17 @@ class Editor extends React.Component {
if (this.props.lintMessages.length > 0 && this.props.lintWarning) { if (this.props.lintMessages.length > 0 && this.props.lintWarning) {
this.beep.play(); this.beep.play();
} }
}) }, 2000)
} }
}); });
this._cm.on('change', debounce(400, () => { this._cm.on('change', debounce(() => {
this.props.setUnsavedChanges(true); this.props.setUnsavedChanges(true);
this.props.updateFileContent(this.props.file.name, this._cm.getValue()); this.props.updateFileContent(this.props.file.name, this._cm.getValue());
if (this.props.autorefresh && this.props.isPlaying) { if (this.props.autorefresh && this.props.isPlaying) {
this.props.startRefreshSketch(); this.props.startRefreshSketch();
} }
})); }, 400));
this._cm.on('keyup', () => { this._cm.on('keyup', () => {
const temp = `line ${parseInt((this._cm.getCursor().line) + 1, 10)}`; const temp = `line ${parseInt((this._cm.getCursor().line) + 1, 10)}`;

View File

@ -74,7 +74,7 @@
"dropzone": "^4.3.0", "dropzone": "^4.3.0",
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^1.0.5",
"eslint-loader": "^1.3.0", "eslint-loader": "^1.3.0",
"express": "^4.13.4", "express": "^4.13.4",
"express-session": "^1.13.0", "express-session": "^1.13.0",
"file-saver": "^1.3.2", "file-saver": "^1.3.2",
"file-type": "^3.8.0", "file-type": "^3.8.0",
@ -83,6 +83,7 @@
"jshint": "^2.9.2", "jshint": "^2.9.2",
"jszip": "^3.0.0", "jszip": "^3.0.0",
"jszip-utils": "0.0.2", "jszip-utils": "0.0.2",
"lodash": "^4.16.4",
"loop-protect": "git+https://git@github.com/sagar-sm/loop-protect.git", "loop-protect": "git+https://git@github.com/sagar-sm/loop-protect.git",
"moment": "^2.14.1", "moment": "^2.14.1",
"mongoose": "^4.4.16", "mongoose": "^4.4.16",
@ -104,7 +105,6 @@
"s3-policy": "^0.2.0", "s3-policy": "^0.2.0",
"shortid": "^2.2.6", "shortid": "^2.2.6",
"srcdoc-polyfill": "^0.2.0", "srcdoc-polyfill": "^0.2.0",
"throttle-debounce": "^1.0.1",
"xhr": "^2.2.1" "xhr": "^2.2.1"
} }
} }