MCPcopy Index your code
hub / github.com/material-shell/material-shell / setTranslation

Method setTranslation

src/utils/transition.ts:42–232  ·  view source on GitHub ↗

Starts a transition. * * Note: The translation animator takes full control over the parenting of the actors until the animation is complete. * When calling this function the actors may be parented in arbitrary ways, they will be reparented to the proper state.

(
        // Entering by translation actors
        enteringActors: Clutter.Actor[],
        // global actors list
        globalContext: Clutter.Actor[],
        direction: number
    )

Source from the content-addressed store, hash-verified

40 * When calling this function the actors may be parented in arbitrary ways, they will be reparented to the proper state.
41 */
42 setTranslation(
43 // Entering by translation actors
44 enteringActors: Clutter.Actor[],
45 // global actors list
46 globalContext: Clutter.Actor[],
47 direction: number
48 ): void {
49 let translationY = this.container.translation_y;
50 let translationX = this.container.translation_x;
51
52 // Determine visible area
53 const visibleArea = {
54 x1: Math.abs(translationX),
55 x2: Math.abs(translationX) + this.container.allocation.get_width(),
56 y1: Math.abs(translationY),
57 y2: Math.abs(translationY) + this.container.allocation.get_height(),
58 };
59
60 /**
61 * If Animation is already in progress we want to remove all actor that are not currently visible on the screen in order to reduce the distance needed to reach the final entering actors
62 */
63 if (this.animationInProgress) {
64 this.container.remove_all_transitions();
65 this.animationInProgress = false;
66
67 // Foreach this.displayed child check if it's in visible bound and hide every one that are outisde and update the current translation accordingly in order to prevent any visible jump
68 this.container
69 .get_children()
70 .filter((actor) => actor.visible)
71 .forEach((actor) => {
72 const allocationBox = this.getTransformedBox(actor);
73 if (this.vertical) {
74 if (allocationBox.y2 < visibleArea.y1) {
75 actor.hide();
76 translationY += InfinityTo0(
77 allocationBox.get_height()
78 );
79 }
80 if (allocationBox.y1 > visibleArea.y2) {
81 actor.hide();
82 }
83 } else {
84 if (allocationBox.x2 < visibleArea.x1) {
85 actor.hide();
86 translationX += InfinityTo0(
87 allocationBox.get_width()
88 );
89 }
90 if (allocationBox.x1 > visibleArea.x2) {
91 actor.hide();
92 }
93 }
94 });
95 }
96
97 /**
98 * For each entering actors we want to be sure that:
99 * 1- their are the child of the container and visible

Callers

nothing calls this directly

Calls 15

getTransformedBoxMethod · 0.95
endTransitionMethod · 0.95
InfinityTo0Function · 0.90
reparentActorFunction · 0.90
filterMethod · 0.80
set_child_at_indexMethod · 0.80
easeMethod · 0.80
get_widthMethod · 0.65
get_heightMethod · 0.65
get_childrenMethod · 0.65
hideMethod · 0.65

Tested by

no test coverage detected