mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +00:00
Use lodash throttle
This commit is contained in:
parent
f517f69175
commit
b877522bce
|
@ -283,8 +283,10 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/highlight.js": "9.1.10",
|
"@types/highlight.js": "9.1.10",
|
||||||
|
"@types/lodash.throttle": "^4.1.3",
|
||||||
"@types/markdown-it": "0.0.2",
|
"@types/markdown-it": "0.0.2",
|
||||||
"@types/node": "7.0.43",
|
"@types/node": "7.0.43",
|
||||||
|
"lodash.throttle": "^4.1.1",
|
||||||
"ts-loader": "^4.0.1",
|
"ts-loader": "^4.0.1",
|
||||||
"typescript": "^2.7.2",
|
"typescript": "^2.7.2",
|
||||||
"vscode": "^1.1.10",
|
"vscode": "^1.1.10",
|
||||||
|
|
|
@ -8,30 +8,7 @@ import { postCommand, postMessage } from './messaging';
|
||||||
import { onceDocumentLoaded } from './events';
|
import { onceDocumentLoaded } from './events';
|
||||||
import { getEditorLineNumberForPageOffset, scrollToRevealSourceLine } from './scroll-sync';
|
import { getEditorLineNumberForPageOffset, scrollToRevealSourceLine } from './scroll-sync';
|
||||||
import { ActiveLineMarker } from './activeLineMarker';
|
import { ActiveLineMarker } from './activeLineMarker';
|
||||||
|
import throttle = require('lodash.throttle');
|
||||||
// From https://remysharp.com/2010/07/21/throttling-function-calls
|
|
||||||
function throttle(fn: (x: any) => any, threshhold: any, scope?: any) {
|
|
||||||
threshhold = threshhold || (threshhold = 250);
|
|
||||||
var last: any, deferTimer: any;
|
|
||||||
return function (this: any, ...x: any[]) {
|
|
||||||
var context = scope || this;
|
|
||||||
|
|
||||||
var now = +new Date,
|
|
||||||
args = arguments;
|
|
||||||
if (last && now < last + threshhold) {
|
|
||||||
// hold on to it
|
|
||||||
clearTimeout(deferTimer);
|
|
||||||
deferTimer = setTimeout(function () {
|
|
||||||
last = now;
|
|
||||||
fn.apply(context, args);
|
|
||||||
}, threshhold + last - now);
|
|
||||||
} else {
|
|
||||||
last = now;
|
|
||||||
fn.apply(context, args);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var scrollDisabled = true;
|
var scrollDisabled = true;
|
||||||
const marker = new ActiveLineMarker();
|
const marker = new ActiveLineMarker();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"module": "es6",
|
"module": "commonjs",
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|
|
@ -10,6 +10,16 @@
|
||||||
version "9.1.10"
|
version "9.1.10"
|
||||||
resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.1.10.tgz#b621f809cd9573b80992b90cffc5788208e3069c"
|
resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.1.10.tgz#b621f809cd9573b80992b90cffc5788208e3069c"
|
||||||
|
|
||||||
|
"@types/lodash.throttle@^4.1.3":
|
||||||
|
version "4.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash.throttle/-/lodash.throttle-4.1.3.tgz#8bfa4fec519d09ebce56c815bcbff3e55c604db9"
|
||||||
|
dependencies:
|
||||||
|
"@types/lodash" "*"
|
||||||
|
|
||||||
|
"@types/lodash@*":
|
||||||
|
version "4.14.104"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80"
|
||||||
|
|
||||||
"@types/markdown-it@0.0.2":
|
"@types/markdown-it@0.0.2":
|
||||||
version "0.0.2"
|
version "0.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.2.tgz#5d9ad19e6e6508cdd2f2596df86fd0aade598660"
|
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.2.tgz#5d9ad19e6e6508cdd2f2596df86fd0aade598660"
|
||||||
|
@ -3277,6 +3287,10 @@ lodash.templatesettings@^3.0.0:
|
||||||
lodash._reinterpolate "^3.0.0"
|
lodash._reinterpolate "^3.0.0"
|
||||||
lodash.escape "^3.0.0"
|
lodash.escape "^3.0.0"
|
||||||
|
|
||||||
|
lodash.throttle@^4.1.1:
|
||||||
|
version "4.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
|
||||||
|
|
||||||
lodash@^4.11.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0:
|
lodash@^4.11.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0:
|
||||||
version "4.17.5"
|
version "4.17.5"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
|
||||||
|
|
Loading…
Reference in a new issue