Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Unified Diff: ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js

Issue 2948973002: [cr-action-menu] Constrain menu to viewport. (Closed)
Patch Set: fix_closure Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_action_menu_test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
diff --git a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js b/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
index b104ea4e0f7b285503f9c08ef393a28e03bcd969..c07e51a2195308f52743a368de812a1f537ca8b1 100644
--- a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
+++ b/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
@@ -39,37 +39,40 @@ var AnchorAlignment = {
* @private
* @param {number} start
* @param {number} end
- * @param {number} length
+ * @param {number} menuLength
* @param {AnchorAlignment} anchorAlignment
* @param {number} min
* @param {number} max
* @return {number}
*/
function getStartPointWithAnchor(
- start, end, length, anchorAlignment, min, max) {
+ start, end, menuLength, anchorAlignment, min, max) {
var startPoint = 0;
switch (anchorAlignment) {
case AnchorAlignment.BEFORE_START:
- startPoint = -length;
+ startPoint = -menuLength;
break;
case AnchorAlignment.AFTER_START:
startPoint = start;
break;
case AnchorAlignment.CENTER:
- startPoint = (start + end - length) / 2;
+ startPoint = (start + end - menuLength) / 2;
break;
case AnchorAlignment.BEFORE_END:
- startPoint = end - length;
+ startPoint = end - menuLength;
break;
case AnchorAlignment.AFTER_END:
startPoint = end;
break;
}
- if (startPoint + length > max)
- startPoint = end - length;
+ if (startPoint + menuLength > max)
+ startPoint = end - menuLength;
if (startPoint < min)
startPoint = start;
+
+ startPoint = Math.max(min, Math.min(startPoint, max - menuLength));
+
return startPoint;
}
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_action_menu_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698