diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-02-22 12:03:39 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-02-22 12:03:39 -0500 |
commit | 66079f2253a0c81bb33c1fee848a6cd2222d43d9 (patch) | |
tree | ca5fdd5f27c24f8d90665cb369e50f4580ce24fc /src/SMAPI.Web/wwwroot/Content/js | |
parent | c8d627cdf2ae3126584ec2500877ff19987db17f (diff) | |
parent | 585b23797e262073e0738069eff61e90819216b7 (diff) | |
download | SMAPI-66079f2253a0c81bb33c1fee848a6cd2222d43d9.tar.gz SMAPI-66079f2253a0c81bb33c1fee848a6cd2222d43d9.tar.bz2 SMAPI-66079f2253a0c81bb33c1fee848a6cd2222d43d9.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/wwwroot/Content/js')
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/mods.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/SMAPI.Web/wwwroot/Content/js/mods.js b/src/SMAPI.Web/wwwroot/Content/js/mods.js index 0394ac4f..35098b60 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/mods.js +++ b/src/SMAPI.Web/wwwroot/Content/js/mods.js @@ -102,7 +102,7 @@ smapi.modList = function (mods, enableBeta) { app = new Vue({ el: "#app", data: data, - mounted: function() { + mounted: function () { // enable table sorting $("#mod-list").tablesorter({ cssHeader: "header", @@ -115,11 +115,7 @@ smapi.modList = function (mods, enableBeta) { $("#search-box").focus(); // jump to anchor (since table is added after page load) - if (location.hash) { - var row = $(location.hash).get(0); - if (row) - row.scrollIntoView(); - } + this.fixHashPosition(); }, methods: { /** @@ -144,6 +140,18 @@ smapi.modList = function (mods, enableBeta) { } }, + /** + * Fix the window position for the current hash. + */ + fixHashPosition: function () { + if (!location.hash) + return; + + var row = $(location.hash); + var target = row.prev().get(0) || row.get(0); + if (target) + target.scrollIntoView(); + }, /** * Get whether a mod matches the current filters. @@ -151,7 +159,7 @@ smapi.modList = function (mods, enableBeta) { * @param {string[]} searchWords The search words to match. * @returns {bool} Whether the mod matches the filters. */ - matchesFilters: function(mod, searchWords) { + matchesFilters: function (mod, searchWords) { var filters = data.filters; // check hash @@ -249,7 +257,9 @@ smapi.modList = function (mods, enableBeta) { } }); app.applyFilters(); + app.fixHashPosition(); window.addEventListener("hashchange", function () { app.applyFilters(); + app.fixHashPosition(); }); }; |