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:
@ -155,10 +155,6 @@ class BaseIcon extends St.Bin {
|
||||
}
|
||||
});
|
||||
|
||||
function clamp(value, min, max) {
|
||||
return Math.max(Math.min(value, max), min);
|
||||
}
|
||||
|
||||
function zoomOutActor(actor) {
|
||||
let [x, y] = actor.get_transformed_position();
|
||||
zoomOutActorAtPos(actor, x, y);
|
||||
@ -182,8 +178,8 @@ function zoomOutActorAtPos(actor, x, y) {
|
||||
let scaledHeight = height * APPICON_ANIMATION_OUT_SCALE;
|
||||
let scaledX = x - (scaledWidth - width) / 2;
|
||||
let scaledY = y - (scaledHeight - height) / 2;
|
||||
let containedX = clamp(scaledX, monitor.x, monitor.x + monitor.width - scaledWidth);
|
||||
let containedY = clamp(scaledY, monitor.y, monitor.y + monitor.height - scaledHeight);
|
||||
let containedX = Math.clamp(scaledX, monitor.x, monitor.x + monitor.width - scaledWidth);
|
||||
let containedY = Math.clamp(scaledY, monitor.y, monitor.y + monitor.height - scaledHeight);
|
||||
|
||||
actorClone.ease({
|
||||
scale_x: APPICON_ANIMATION_OUT_SCALE,
|
||||
|
Reference in New Issue
Block a user