From d89900904448feb8023d97e910faf990c627c6f7 Mon Sep 17 00:00:00 2001 From: Tomas Chmelevskij Date: Tue, 31 Jan 2023 16:27:38 +0100 Subject: [PATCH] feat: drop jquery debounce for local implementation (#3296) --- libraries/jquery.ba-throttle-debounce.min.js | 9 --------- package.json | 1 + src/js/tabs/osd.js | 5 +++-- src/main.html | 1 - yarn.lock | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 libraries/jquery.ba-throttle-debounce.min.js diff --git a/libraries/jquery.ba-throttle-debounce.min.js b/libraries/jquery.ba-throttle-debounce.min.js deleted file mode 100644 index 07205508..00000000 --- a/libraries/jquery.ba-throttle-debounce.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * jQuery throttle / debounce - v1.1 - 3/7/2010 - * http://benalman.com/projects/jquery-throttle-debounce-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ -(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); \ No newline at end of file diff --git a/package.json b/package.json index 73dca0de..0584eb4b 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "jquery-touchswipe": "^1.6.19", "jquery-ui-npm": "^1.12.0", "jsdom": "^21.0.0", + "lodash.debounce": "^4.0.8", "marked": "^4.1.1", "multicast-dns": "^7.2.5", "multiple-select": "^1.5.2", diff --git a/src/js/tabs/osd.js b/src/js/tabs/osd.js index efb2f7ff..2a51e3ec 100644 --- a/src/js/tabs/osd.js +++ b/src/js/tabs/osd.js @@ -14,6 +14,7 @@ import semver from "semver"; import jBox from "jbox"; import inflection from "inflection"; import { checkChromeRuntimeError } from "../utils/common"; +import debounce from "lodash.debounce"; const FONT = {}; const SYM = {}; @@ -3085,7 +3086,7 @@ osd.initialize = function(callback) { $(``) .data('field', field) .val(field.position) - .change($.debounce(250, function() { + .change(debounce(function() { const fieldChanged = $(this).data('field'); const position = parseInt($(this).val()); fieldChanged.position = position; @@ -3093,7 +3094,7 @@ osd.initialize = function(callback) { .then(function() { updateOsdView(); }); - })), + }, 250)), ); } diff --git a/src/main.html b/src/main.html index 12f7cd17..860f413c 100644 --- a/src/main.html +++ b/src/main.html @@ -62,7 +62,6 @@ - diff --git a/yarn.lock b/yarn.lock index 86f435fc..a2a375cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10314,7 +10314,7 @@ lodash._root@^3.0.0: lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" - integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= + integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow== lodash.defaults@^4.2.0: version "4.2.0"