|
4 | 4 | :host {
|
5 | 5 | /**
|
6 | 6 | * @prop --animatable-cube-size: Size of the cube
|
| 7 | + * @prop --animatable-cube-width: Width of the cube |
| 8 | + * @prop --animatable-cube-height: Height of the cube |
7 | 9 | * @prop --animatable-cube-perspective: Perspective of the cube
|
8 | 10 | * @prop --animatable-cube-perspective-origin: Indicates the position of the abscissa and the ordinate of the vanishing point.
|
9 | 11 | * @prop --animatable-cube-display: Display of the cube
|
|
15 | 17 | * @prop --animatable-cube-justify-content: Justify content of the cube
|
16 | 18 | * @prop --animatable-cube-margin: Margin of the cube
|
17 | 19 | * @prop --animatable-cube-padding: Padding of the cube
|
| 20 | + * @prop --animatable-cube-transform: Transform of the cube |
| 21 | + * @prop --animatable-cube-transform-origin: Transform origin of the cube |
| 22 | + * @prop --animatable-cube-animation: Animation of the cube |
18 | 23 | *
|
19 | 24 | * @prop --animatable-cube-face-border: Cube faces border
|
20 | 25 | * @prop --animatable-cube-face-background: Cube faces background
|
|
25 | 30 | * @prop --animatable-cube-face-animation-delay: Defines when the background animation will start
|
26 | 31 | * @prop --animatable-cube-face-animation-iteration-count: Defines the number of times the background animation cycle is played
|
27 | 32 | * @prop --animatable-cube-face-animation-direction: Defines the direction of the background animation
|
| 33 | + * @prop --animatable-cube-face-transform-origin: Establishes the origin of transformation for the cube faces |
28 | 34 | *
|
29 | 35 | * @prop --animatable-cube-front-face-background: Background of the front face
|
30 | 36 | * @prop --animatable-cube-front-face-animation: Animation of the front face
|
|
40 | 46 | * @prop --animatable-cube-bottom-face-animation: Animation of the bottom face
|
41 | 47 | */
|
42 | 48 |
|
43 |
| - --size: var(--animatable-cube-size, 100px); |
| 49 | + --size: var(--animatable-cube-size, var(--animatable-cube-width, var(--animatable-cube-height, 100px))); |
44 | 50 | --perspective: var(--animatable-cube-perspective, 1000px);
|
45 | 51 | --perspective-origin: var(--animatable-cube-perspective-origin, 50% 50%);
|
46 | 52 |
|
|
54 | 60 | --margin: var(--animatable-cube-margin, 0);
|
55 | 61 | --padding: var(--animatable-cube-padding, 0);
|
56 | 62 |
|
57 |
| - --border: var(--animatable-cube-face-border, none); |
58 |
| - --background: var(--animatable-cube-face-background, white); |
59 |
| - --background-size: var(--animatable-cube-face-background-size, 100% 100%); |
60 |
| - --animation: var( |
| 63 | + --face-border: var(--animatable-cube-face-border, none); |
| 64 | + --face-background: var(--animatable-cube-face-background, white); |
| 65 | + --face-background-size: var(--animatable-cube-face-background-size, 100% 100%); |
| 66 | + --face-animation: var( |
61 | 67 | --animatable-cube-face-animation,
|
62 | 68 | backgroundAnimation
|
63 | 69 | var(--animatable-cube-face-animation-duration, 0s)
|
|
67 | 73 | var(--animatable-cube-face-animation-direction, alternate)
|
68 | 74 | );
|
69 | 75 |
|
| 76 | + --face-size: calc(var(--size)/2); |
| 77 | + --face-transform-origin: var(--animatable-cube-face-transform-origin, center center); |
| 78 | + |
70 | 79 | perspective: var(--perspective);
|
71 | 80 | perspective-origin: var(--perspective-origin);
|
72 | 81 | padding: var(--padding);
|
|
90 | 99 | position: relative;
|
91 | 100 | background: transparent;
|
92 | 101 | transform-style: preserve-3d;
|
93 |
| - transform: translateZ(-calc(var(--size)/2)); |
| 102 | + transform: var(--animatable-cube-transform, translateZ(-var(--face-size))); |
| 103 | + transform-origin: var(--animatable-cube-transform-origin, initial); |
94 | 104 | transition: transform var(--transition-duration);
|
95 | 105 | }
|
96 | 106 | .face {
|
97 |
| - background: var(--animatable-cube-face-background, transparent); |
| 107 | + background: var(--animatable-cube-face-background, var(--face-background)); |
98 | 108 | position: absolute;
|
99 | 109 | height: 100%;
|
100 | 110 | width: 100%;
|
101 |
| - border: var(--border); |
| 111 | + border: var(--face-border); |
102 | 112 | transition: transform var(--transition-duration);
|
| 113 | + transform-origin: var(--face-transform-origin); |
103 | 114 | }
|
104 | 115 | .front {
|
105 | 116 | transform:
|
106 | 117 | rotateY(0deg)
|
107 |
| - translateZ(calc(var(--size)/2)); |
| 118 | + translateZ(var(--face-size)); |
108 | 119 | will-change: transform;
|
109 |
| - background: var(--animatable-cube-front-face-background, var(--background)); |
110 |
| - background-size: var(--animatable-cube-front-face-background-size, var(--background-size)); |
111 |
| - animation: var(--animatable-cube-front-face-animation, var(--animation)); |
| 120 | + background: var(--animatable-cube-front-face-background, var(--face-background)); |
| 121 | + background-size: var(--animatable-cube-front-face-background-size, var(--face-background-size)); |
| 122 | + animation: var(--animatable-cube-front-face-animation, var(--face-animation)); |
112 | 123 | }
|
113 | 124 | .back {
|
114 | 125 | transform:
|
115 | 126 | rotateY(180deg)
|
116 |
| - translateZ(calc(var(--size)/2)); |
| 127 | + translateZ(var(--face-size)); |
117 | 128 | will-change: transform;
|
118 |
| - background: var(--animatable-cube-back-face-background, var(--background)); |
119 |
| - background-size: var(--animatable-cube-back-face-background-size, var(--background-size)); |
120 |
| - animation: var(--animatable-cube-back-face-animation, var(--animation)); |
| 129 | + background: var(--animatable-cube-back-face-background, var(--face-background)); |
| 130 | + background-size: var(--animatable-cube-back-face-background-size, var(--face-background-size)); |
| 131 | + animation: var(--animatable-cube-back-face-animation, var(--face-animation)); |
121 | 132 | }
|
122 | 133 | .right {
|
123 | 134 | transform:
|
124 | 135 | rotateY(90deg)
|
125 |
| - translateZ(calc(var(--size)/2)); |
| 136 | + translateZ(var(--face-size)); |
126 | 137 | will-change: transform;
|
127 |
| - background: var(--animatable-cube-right-face-background, var(--background)); |
128 |
| - background-size: var(--animatable-cube-right-face-background-size, var(--background-size)); |
129 |
| - animation: var(--animatable-cube-right-face-animation, var(--animation)); |
| 138 | + background: var(--animatable-cube-right-face-background, var(--face-background)); |
| 139 | + background-size: var(--animatable-cube-right-face-background-size, var(--face-background-size)); |
| 140 | + animation: var(--animatable-cube-right-face-animation, var(--face-animation)); |
130 | 141 | }
|
131 | 142 | .left {
|
132 | 143 | transform:
|
133 | 144 | rotateY(-90deg)
|
134 |
| - translateZ(calc(var(--size)/2)); |
| 145 | + translateZ(var(--face-size)); |
135 | 146 | will-change: transform;
|
136 |
| - background: var(--animatable-cube-left-face-background, var(--background)); |
137 |
| - background-size: var(--animatable-cube-left-face-background-size, var(--background-size)); |
138 |
| - animation: var(--animatable-cube-left-face-animation, var(--animation)); |
| 147 | + background: var(--animatable-cube-left-face-background, var(--face-background)); |
| 148 | + background-size: var(--animatable-cube-left-face-background-size, var(--face-background-size)); |
| 149 | + animation: var(--animatable-cube-left-face-animation, var(--face-animation)); |
139 | 150 | }
|
140 | 151 | .top {
|
141 | 152 | transform:
|
142 | 153 | rotateX(90deg)
|
143 |
| - translateZ(calc(var(--size)/2)); |
| 154 | + translateZ(var(--face-size)); |
144 | 155 | will-change: transform;
|
145 |
| - background: var(--animatable-cube-top-face-background, var(--background)); |
146 |
| - background-size: var(--animatable-cube-top-face-background-size, var(--background-size)); |
147 |
| - animation: var(--animatable-cube-top-face-animation, var(--animation)); |
| 156 | + background: var(--animatable-cube-top-face-background, var(--face-background)); |
| 157 | + background-size: var(--animatable-cube-top-face-background-size, var(--face-background-size)); |
| 158 | + animation: var(--animatable-cube-top-face-animation, var(--face-animation)); |
148 | 159 | }
|
149 | 160 | .bottom {
|
150 | 161 | transform:
|
151 | 162 | rotateX(-90deg)
|
152 |
| - translateZ(calc(var(--size)/2)); |
| 163 | + translateZ(var(--face-size)); |
153 | 164 | will-change: transform;
|
154 |
| - background: var(--animatable-cube-bottom-face-background, var(--background)); |
155 |
| - background-size: var(--animatable-cube-bottom-face-background-size, var(--background-size)); |
156 |
| - animation: var(--animatable-cube-bottom-face-animation, var(--animation)); |
| 165 | + background: var(--animatable-cube-bottom-face-background, var(--face-background)); |
| 166 | + background-size: var(--animatable-cube-bottom-face-background-size, var(--face-background-size)); |
| 167 | + animation: var(--animatable-cube-bottom-face-animation, var(--face-animation)); |
157 | 168 | }
|
158 | 169 |
|
159 | 170 | /* Animation Keyframes */
|
|
0 commit comments