environment: Add Math.clamp
The good old clamp function, now part of the Math family. Clamp is happy after so many years of loneliness. This is a strict implementation of the draft ECMAScript proposal. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1295
This commit is contained in:
@ -72,10 +72,6 @@ function _getFolderName(folder) {
|
||||
return name;
|
||||
}
|
||||
|
||||
function clamp(value, min, max) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
function _getViewFromIcon(icon) {
|
||||
for (let parent = icon.get_parent(); parent; parent = parent.get_parent()) {
|
||||
if (parent instanceof BaseAppView)
|
||||
@ -627,7 +623,7 @@ class AppDisplay extends BaseAppView {
|
||||
}
|
||||
|
||||
goToPage(pageNumber, animate = true) {
|
||||
pageNumber = clamp(pageNumber, 0, this._grid.nPages() - 1);
|
||||
pageNumber = Math.clamp(pageNumber, 0, this._grid.nPages() - 1);
|
||||
|
||||
if (this._grid.currentPage === pageNumber &&
|
||||
this._displayingDialog &&
|
||||
|
Reference in New Issue
Block a user