@sbb-esta/lyne-elements-dev 5.1.0-dev.1782310350 → 5.1.0-dev.1782312497
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clock.pure.js +1 -1
- package/custom-elements.json +3 -3
- package/development/clock.pure.js +15 -17
- package/package.json +2 -2
package/clock.pure.js
CHANGED
|
@@ -3,7 +3,7 @@ import{__esDecorate as e,__runInitializers as t}from"tslib";import{html as n,isS
|
|
|
3
3
|
`,u=`<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 105 105"><path d="M55.1,64.5h-5.2l0.8-58h3.6L55.1,64.5z"/></svg>
|
|
4
4
|
`,d=`<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 105 105"><path d="M57.8,21.3c0-2.9-2.4-5.2-5.2-5.2s-5.3,2.3-5.3,5.2c0,2.7,2,4.8,4.5,5.2V69h1.5V26.5C55.8,26.2,57.8,24,57.8,21.3z"/></svg>
|
|
5
5
|
`,f=`:host{aspect-ratio:1;contain:content;display:block;position:relative;overflow:hidden}.sbb-clock__face,.sbb-clock__hand-hours,.sbb-clock__hand-minutes,.sbb-clock__hand-seconds{transform-origin:50%;transform-style:preserve-3d;backface-visibility:hidden;position:absolute;inset:0;transform:rotate(0)}.sbb-clock__hand-hours,.sbb-clock__hand-minutes,.sbb-clock__face{fill:var(--sbb-clock-face-color)}.sbb-clock__hand-minutes{transition:transform var(--sbb-disable-animation-duration,.2s) cubic-bezier(.4, 2.08, .55, .44)}@supports not (aspect-ratio:1/1){.sbb-clock__hand-minutes{transform-origin:50% 49.625%}}.sbb-clock__hand-hours{animation-name:rotate;animation-duration:43200s;animation-timing-function:linear;animation-iteration-count:infinite;animation-play-state:var(--sbb-clock-animation-play-state,"paused")}.sbb-clock__hand-hours--initial-hour{animation-name:hand-hours-animation-initial-hour;animation-duration:var(--sbb-clock-hours-animation-duration,0s);animation-play-state:var(--sbb-clock-animation-play-state,"paused");animation-iteration-count:1}.sbb-clock__hand-minutes--no-transition{transition:none}.sbb-clock__hand-seconds{animation-name:hand-seconds-animation;animation-duration:60s;animation-timing-function:linear;animation-play-state:var(--sbb-clock-animation-play-state,"paused");fill:var(--sbb-clock-seconds-hand-color);animation-iteration-count:infinite}.sbb-clock__hand-seconds--initial-minute{animation-name:hand-seconds-animation-initial-minute;animation-duration:var(--sbb-clock-seconds-animation-duration,0s);animation-play-state:var(--sbb-clock-animation-play-state,"paused");animation-iteration-count:1}:host(:not(:is(:state(initialized),[state--initialized]))) :is(.sbb-clock__hand-hours,.sbb-clock__hand-minutes,.sbb-clock__hand-seconds){display:none}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes hand-hours-animation-initial-hour{0%{transform:rotateZ(var(--sbb-clock-hours-animation-start-angle,0deg))}to{transform:rotate(360deg)}}@keyframes hand-seconds-animation{0%{transform:rotate(0)}97.5%,to{transform:rotate(360deg)}}@keyframes hand-seconds-animation-initial-minute{0%{transform:rotateZ(var(--sbb-clock-seconds-animation-start-angle,0deg))}97.5%,to{transform:rotate(360deg)}}
|
|
6
|
-
`;const p={once:!0,passive:!0};let m=(()=>{let m=s,h,g=[],_=[];return class extends m{constructor(){super(...arguments),this.#e=t(this,g,null),this._state=(t(this,_),`paused`),this._moveHoursHandFn=()=>this._moveHoursHand(),this._moveMinutesHandFn=()=>this._moveMinutesHand(),this._handlePageVisibilityChange=
|
|
6
|
+
`;const p={once:!0,passive:!0};let m=(()=>{let m=s,h,g=[],_=[];return class extends m{constructor(){super(...arguments),this.#e=t(this,g,null),this._state=(t(this,_),`paused`),this._moveHoursHandFn=()=>this._moveHoursHand(),this._moveMinutesHandFn=()=>this._moveMinutesHand(),this._handlePageVisibilityChange=()=>{this.now||(document.visibilityState===`hidden`?this._stopClock():this._startClock())}}static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;h=[a()],e(this,null,h,{kind:`accessor`,name:`now`,static:!1,private:!1,access:{has:e=>`now`in e,get:e=>e.now,set:(e,t)=>{e.now=t}},metadata:t},g,_),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-clock`}static{this.styles=[i(f)]}#e;get now(){return this.#e}set now(e){this.#e=e}connectedCallback(){super.connectedCallback(),this._resetIntervalId=setInterval(()=>this._resetClock(),1800*1e3)}willUpdate(e){super.willUpdate(e),!(r||!this.hasUpdated)&&e.has(`now`)&&this._startOrConfigureClock()}firstUpdated(e){super.firstUpdated(e),r||(document.addEventListener(`visibilitychange`,this._handlePageVisibilityChange,!1),this._startOrConfigureClock())}disconnectedCallback(){super.disconnectedCallback(),this._removeEventListeners(),clearInterval(this._resetIntervalId)}_startOrConfigureClock(){this.now?(this._stopClock(),this._resetSecondsHandAnimation(),this._setHandsStartingPosition()):this._startClock()}_startClock(){this._clockHandHours?.addEventListener(`animationend`,this._moveHoursHandFn,p),this._clockHandSeconds?.addEventListener(`animationend`,this._moveMinutesHandFn,p),this._setHandsStartingPosition(),this.style?.setProperty(`--sbb-clock-animation-play-state`,`running`),this._state=`running`}_stopClock(){clearInterval(this._handMovement),this._removeSecondsAnimationStyles(),this._removeHoursAnimationStyles(),this._clockHandHours?.removeEventListener(`animationend`,this._moveHoursHandFn),this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),this._clockHandMinutes?.classList.add(`sbb-clock__hand-minutes--no-transition`),this.style?.setProperty(`--sbb-clock-animation-play-state`,`paused`),this._state=`paused`}async _resetClock(){this._state===`running`&&(this._stopClock(),setTimeout(()=>this._startClock(),50))}_setHandsStartingPosition(){this._assignCurrentTime();let e=60-this._seconds,t=60-this._minutes,n=12-this._hours,r=0,i=0;e>0&&(r+=e,i=1),t>0&&(r+=(t-i)*60,i=1),n>0&&(r+=(n-i)*3600),this.style?.setProperty(`--sbb-clock-hours-animation-start-angle`,`${Math.ceil(this._hours*30+this._minutes/2)}deg`),this.style?.setProperty(`--sbb-clock-hours-animation-duration`,`${r}s`),this.style?.setProperty(`--sbb-clock-seconds-animation-start-angle`,`${Math.ceil(this._seconds*6.153846153846154)}deg`),this.style?.setProperty(`--sbb-clock-seconds-animation-duration`,`${e}s`),this._setMinutesHand(),this._clockHandSeconds?.classList.add(`sbb-clock__hand-seconds--initial-minute`),this._clockHandHours?.classList.add(`sbb-clock__hand-hours--initial-hour`),this.internals.states.add(`initialized`)}_assignCurrentTime(){let e=this.now?null:new Date,[t,n,r]=e?[e.getHours(),e.getMinutes(),e.getSeconds()]:this.now.split(`:`).map(e=>+e);this._hours=t%12,this._minutes=n,this._seconds=r}_setMinutesHand(){this._clockHandMinutes?.style.setProperty(`transform`,`rotateZ(${Math.ceil(this._minutes*6)}deg)`)}_moveHoursHand(){this._removeHoursAnimationStyles();let e=Math.ceil(this._hours*30+this._minutes/2);e>=360&&(e-=360),this._clockHandHours?.style.setProperty(`transform`,`rotateZ(${e}deg)`)}_moveMinutesHand(){this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),this._removeSecondsAnimationStyles(),this._addMinutesAndSetHands(),this._handMovement=setInterval(()=>this._addMinutesAndSetHands(),60*1e3)}_addMinutesAndSetHands(){this._minutes++,this._setMinutesHand()}_resetSecondsHandAnimation(){this._clockHandSeconds&&(this._clockHandSeconds.style.animation=``,this._clockHandSeconds.offsetHeight,this._clockHandSeconds.style.removeProperty(`animation`))}_removeEventListeners(){document?.removeEventListener(`visibilitychange`,this._handlePageVisibilityChange),this._clockHandHours?.removeEventListener(`animationend`,this._moveHoursHandFn),this._clockHandSeconds?.removeEventListener(`animationend`,this._moveMinutesHandFn),clearInterval(this._handMovement)}_removeHoursAnimationStyles(){this._clockHandHours?.classList.remove(`sbb-clock__hand-hours--initial-hour`),this.style.removeProperty(`--sbb-clock-hours-animation-start-angle`),this.style.removeProperty(`--sbb-clock-hours-animation-duration`)}_removeSecondsAnimationStyles(){this._clockHandSeconds?.classList.remove(`sbb-clock__hand-seconds--initial-minute`),this._clockHandMinutes?.classList.remove(`sbb-clock__hand-minutes--no-transition`),this.style.removeProperty(`--sbb-clock-seconds-animation-start-angle`),this.style.removeProperty(`--sbb-clock-seconds-animation-duration`)}render(){return n`
|
|
7
7
|
<span class="sbb-clock__face" .innerHTML=${c}></span>
|
|
8
8
|
<span
|
|
9
9
|
class="sbb-clock__hand-hours"
|
package/custom-elements.json
CHANGED
|
@@ -88671,7 +88671,7 @@
|
|
|
88671
88671
|
"privacy": "private",
|
|
88672
88672
|
"return": {
|
|
88673
88673
|
"type": {
|
|
88674
|
-
"text": "
|
|
88674
|
+
"text": "void"
|
|
88675
88675
|
}
|
|
88676
88676
|
}
|
|
88677
88677
|
},
|
|
@@ -88681,7 +88681,7 @@
|
|
|
88681
88681
|
"privacy": "private",
|
|
88682
88682
|
"return": {
|
|
88683
88683
|
"type": {
|
|
88684
|
-
"text": "
|
|
88684
|
+
"text": "void"
|
|
88685
88685
|
}
|
|
88686
88686
|
},
|
|
88687
88687
|
"description": "Starts the clock by defining the hands starting position then starting the animations."
|
|
@@ -88692,7 +88692,7 @@
|
|
|
88692
88692
|
"privacy": "private",
|
|
88693
88693
|
"return": {
|
|
88694
88694
|
"type": {
|
|
88695
|
-
"text": "
|
|
88695
|
+
"text": "void"
|
|
88696
88696
|
}
|
|
88697
88697
|
},
|
|
88698
88698
|
"description": "Stops the clock by removing all the animations."
|
|
@@ -69,10 +69,10 @@ let SbbClockElement = (() => {
|
|
|
69
69
|
this._moveHoursHandFn = () => this._moveHoursHand();
|
|
70
70
|
/** Callback function for minutes hand. */
|
|
71
71
|
this._moveMinutesHandFn = () => this._moveMinutesHand();
|
|
72
|
-
this._handlePageVisibilityChange =
|
|
72
|
+
this._handlePageVisibilityChange = () => {
|
|
73
73
|
if (this.now) return;
|
|
74
|
-
if (document.visibilityState === "hidden")
|
|
75
|
-
else
|
|
74
|
+
if (document.visibilityState === "hidden") this._stopClock();
|
|
75
|
+
else this._startClock();
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
static {
|
|
@@ -122,7 +122,8 @@ let SbbClockElement = (() => {
|
|
|
122
122
|
}
|
|
123
123
|
willUpdate(changedProperties) {
|
|
124
124
|
super.willUpdate(changedProperties);
|
|
125
|
-
if (
|
|
125
|
+
if (isServer || !this.hasUpdated) return;
|
|
126
|
+
if (changedProperties.has("now")) this._startOrConfigureClock();
|
|
126
127
|
}
|
|
127
128
|
firstUpdated(changedProperties) {
|
|
128
129
|
super.firstUpdated(changedProperties);
|
|
@@ -136,26 +137,23 @@ let SbbClockElement = (() => {
|
|
|
136
137
|
this._removeEventListeners();
|
|
137
138
|
clearInterval(this._resetIntervalId);
|
|
138
139
|
}
|
|
139
|
-
|
|
140
|
+
_startOrConfigureClock() {
|
|
140
141
|
if (this.now) {
|
|
141
|
-
|
|
142
|
+
this._stopClock();
|
|
142
143
|
this._resetSecondsHandAnimation();
|
|
143
144
|
this._setHandsStartingPosition();
|
|
144
|
-
} else
|
|
145
|
+
} else this._startClock();
|
|
145
146
|
}
|
|
146
147
|
/** Starts the clock by defining the hands starting position then starting the animations. */
|
|
147
|
-
|
|
148
|
+
_startClock() {
|
|
148
149
|
this._clockHandHours?.addEventListener("animationend", this._moveHoursHandFn, ADD_EVENT_LISTENER_OPTIONS);
|
|
149
150
|
this._clockHandSeconds?.addEventListener("animationend", this._moveMinutesHandFn, ADD_EVENT_LISTENER_OPTIONS);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this._state = "running";
|
|
154
|
-
resolve();
|
|
155
|
-
}, INITIAL_TIMEOUT_DURATION));
|
|
151
|
+
this._setHandsStartingPosition();
|
|
152
|
+
this.style?.setProperty("--sbb-clock-animation-play-state", "running");
|
|
153
|
+
this._state = "running";
|
|
156
154
|
}
|
|
157
155
|
/** Stops the clock by removing all the animations. */
|
|
158
|
-
|
|
156
|
+
_stopClock() {
|
|
159
157
|
clearInterval(this._handMovement);
|
|
160
158
|
this._removeSecondsAnimationStyles();
|
|
161
159
|
this._removeHoursAnimationStyles();
|
|
@@ -170,8 +168,8 @@ let SbbClockElement = (() => {
|
|
|
170
168
|
*/
|
|
171
169
|
async _resetClock() {
|
|
172
170
|
if (this._state !== "running") return;
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
this._stopClock();
|
|
172
|
+
setTimeout(() => this._startClock(), INITIAL_TIMEOUT_DURATION);
|
|
175
173
|
}
|
|
176
174
|
/** Set the starting position for the three hands on the clock face. */
|
|
177
175
|
_setHandsStartingPosition() {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbb-esta/lyne-elements-dev",
|
|
3
|
-
"version": "5.1.0-dev.
|
|
3
|
+
"version": "5.1.0-dev.1782312497",
|
|
4
4
|
"description": "Lyne Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design system",
|
|
7
7
|
"web components",
|
|
8
8
|
"lit",
|
|
9
|
-
"https://github.com/sbb-design-systems/lyne-components/commit/
|
|
9
|
+
"https://github.com/sbb-design-systems/lyne-components/commit/d3381c22c3c03cbccf501b4791ce47da9ef6d405"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|