Skip to content

Commit 6519994

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
[RPP] When only one entry of the link annotation is visible, make the line short
Bug: 395567506 Change-Id: Ie1519a026b387c26b1e93721eab01554a184098f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6439365 Auto-Submit: Alina Varkki <alinavarkki@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
1 parent 1b9024a commit 6519994

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

front_end/panels/timeline/overlays/components/EntriesLinkOverlay.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,33 +274,24 @@ export class EntriesLinkOverlay extends HTMLElement {
274274
}
275275

276276
/*
277-
* When only one entry from the connection is visible, the connection
278-
* line becomes a gradient from the visible entry to the edge of
279-
* the screen towards the entry that is not visible.
277+
* Calculates the gradient stop percentage when only one entry is visible.
278+
* This percentage represents the portion of the line visible within the canvas,
279+
* used to create a fade effect towards the off-screen entry.
280+
* When one entry is off-screen, it is impossible to tell where exactly the line
281+
* is going to. Therefore, to not needlessly take space, the faded line is very short.
280282
*
281283
* To achieve this, we need to calculate what percentage of the
282-
* visible screen the connection is currently occupying and apply
284+
* shole connection the short line is currently occupying and apply
283285
* that gradient to the visible connection part.
284286
*/
285287
#partlyVisibleConnectionLinePercentage(): number {
286288
if (!this.#canvasRect) {
287289
return 100;
288290
}
291+
const fadedLineLength = 25;
289292

290293
const lineLength = this.#coordinateTo.x - (this.#coordinateFrom.x + this.#fromEntryDimensions.width);
291-
let visibleLineLength = 0;
292-
293-
// If the visible entry is the 'From' entry, find the length of the visible arrow by
294-
// subtracting the point where the arrow starts from the whole canvas length.
295-
// If the 'to' entry is visible, the coordinate of the entry will be equal to
296-
// the visible arrow length.
297-
if (this.#entryFromVisible && !this.#entryToVisible) {
298-
visibleLineLength = this.#canvasRect.width - (this.#coordinateFrom.x + this.#fromEntryDimensions.width);
299-
} else if (!this.#entryFromVisible && this.#entryToVisible) {
300-
visibleLineLength = this.#coordinateTo.x;
301-
}
302-
303-
const visibleLineFromTotalPercentage = (visibleLineLength * 100) / lineLength;
294+
const visibleLineFromTotalPercentage = (fadedLineLength * 100) / lineLength;
304295

305296
return (visibleLineFromTotalPercentage < 100) ? visibleLineFromTotalPercentage : 100;
306297
}

0 commit comments

Comments
 (0)