Skip to content

Commit

Permalink
Refactor js code to be ES5 compatible.
Browse files Browse the repository at this point in the history
TODO: replace uglify because it does not support es6
  • Loading branch information
stavroskasidis committed Dec 21, 2023
1 parent aa83f09 commit a933588
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion BlazorContextMenu/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gulp.task("clean:css", function (cb) {
});

gulp.task("min:css", function () {
return gulp.src(["wwwroot/**/*.css", "!wwwroot/**/*.css.js"], { base: "." })
return gulp.src(["wwwroot/**/*.css", "!wwwroot/**/*.min.css"], { base: "." })
.pipe(cssmin())
.pipe(rename({
suffix: ".min"
Expand Down
15 changes: 7 additions & 8 deletions BlazorContextMenu/wwwroot/blazorContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ var blazorContextMenu = function (blazorContextMenu) {
}
}

const sleepUntil = async (f, timeoutMs) => {
return new Promise((resolve, reject) => {
const timeWas = new Date();
const wait = setInterval(function () {
var sleepUntil = function (f, timeoutMs) {
return new Promise(function (resolve, reject){
var timeWas = new Date();
var wait = setInterval(function () {
if (f()) {
clearInterval(wait);
resolve();
Expand Down Expand Up @@ -135,10 +135,9 @@ var blazorContextMenu = function (blazorContextMenu) {
};

var showMenuCommon = function (menu, menuId, x, y, target, triggerDotnetRef) {
return blazorContextMenu.Show(menuId, x, y, target, triggerDotnetRef).then(async function () {

await sleepUntil(() => menu.clientWidth > 0, 1000); //Wait until the menu has spawned so clientWidth and offsetLeft report correctly

return blazorContextMenu.Show(menuId, x, y, target, triggerDotnetRef).then(function () {
return sleepUntil(function () { return menu.clientWidth > 0 }, 1000); //Wait until the menu has spawned so clientWidth and offsetLeft report correctly
}).then(function () {
//check for overflow
var leftOverflownPixels = menu.offsetLeft + menu.clientWidth - window.innerWidth;
if (leftOverflownPixels > 0) {
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.301"
"version": "6.0.417"
}
}

0 comments on commit a933588

Please sign in to comment.