@operato/scene-news-ticker 0.1.5
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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/news-ticker-element.d.ts +16 -0
- package/dist/news-ticker-element.js +80 -0
- package/dist/news-ticker-element.js.map +1 -0
- package/dist/news-ticker-horizontal.d.ts +17 -0
- package/dist/news-ticker-horizontal.js +129 -0
- package/dist/news-ticker-horizontal.js.map +1 -0
- package/dist/news-ticker-vertical.d.ts +22 -0
- package/dist/news-ticker-vertical.js +126 -0
- package/dist/news-ticker-vertical.js.map +1 -0
- package/dist/news-ticker.d.ts +39 -0
- package/dist/news-ticker.js +97 -0
- package/dist/news-ticker.js.map +1 -0
- package/helps/scene/component/news-ticker.ko.md +27 -0
- package/helps/scene/component/news-ticker.md +27 -0
- package/helps/scene/component/news-ticker.zh.md +27 -0
- package/helps/scene/images/news_ticker_1.png +0 -0
- package/helps/scene/images/news_ticker_2.png +0 -0
- package/helps/scene/images/news_ticker_3.png +0 -0
- package/helps/scene/images/news_ticker_video_1.gif +0 -0
- package/helps/scene/images/news_ticker_video_2.gif +0 -0
- package/icons/icon-news-ticker.png +0 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +20 -0
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +20 -0
- package/logs/application-2022-02-10-10.log +37 -0
- package/logs/application-2022-02-10-11.log +8 -0
- package/logs/connections-2022-02-10-10.log +288 -0
- package/logs/connections-2022-02-10-11.log +64 -0
- package/package.json +63 -0
- package/src/index.ts +5 -0
- package/src/news-ticker-element.ts +51 -0
- package/src/news-ticker-horizontal.ts +128 -0
- package/src/news-ticker-vertical.ts +125 -0
- package/src/news-ticker.ts +128 -0
- package/test/basic-test.html +81 -0
- package/test/index.html +22 -0
- package/test/unit/test-news-ticker.js +33 -0
- package/test/unit/util.js +22 -0
- package/things-scene.config.js +24 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
### [0.1.5](https://github.com/things-scene/operato-scene/compare/v0.1.4...v0.1.5) (2022-02-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
* move news-ticker to here ([c5e565d](https://github.com/things-scene/operato-scene/commit/c5e565dff6016977766e54b3b74c4f80838f7cd2))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Hearty, Oh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<h1 align="center">Welcome to @things-scene/news-ticker 👋</h1>
|
|
2
|
+
<p>
|
|
3
|
+
<img src="https://img.shields.io/badge/version-1.0.0-beta-blue.svg?cacheSeconds=2592000" />
|
|
4
|
+
<a href="https://github.com/things-scene/things-scene-news-ticker#readme">
|
|
5
|
+
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" target="_blank" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://github.com/things-scene/things-scene-news-ticker/graphs/commit-activity">
|
|
8
|
+
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" target="_blank" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://github.com/things-scene/things-scene-news-ticker/blob/master/LICENSE">
|
|
11
|
+
<img alt="License: ISC" src="https://img.shields.io/badge/License-ISC-yellow.svg" target="_blank" />
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
> News ticker Component for Things Scene.
|
|
16
|
+
|
|
17
|
+
### 🏠 [Homepage](https://github.com/things-scene/things-scene-news-ticker#readme)
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Author
|
|
26
|
+
|
|
27
|
+
👤 **lotstar87**
|
|
28
|
+
|
|
29
|
+
* Github: [@lotstar87](https://github.com/lotstar87)
|
|
30
|
+
|
|
31
|
+
## 🤝 Contributing
|
|
32
|
+
|
|
33
|
+
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/things-scene/things-scene-news-ticker/issues).
|
|
34
|
+
|
|
35
|
+
## Show your support
|
|
36
|
+
|
|
37
|
+
Give a ⭐️ if this project helped you!
|
|
38
|
+
|
|
39
|
+
## 📝 License
|
|
40
|
+
|
|
41
|
+
Copyright © 2019 [lotstar87](https://github.com/lotstar87).<br />
|
|
42
|
+
This project is [ISC](https://github.com/things-scene/things-scene-news-ticker/blob/master/LICENSE) licensed.
|
|
43
|
+
|
|
44
|
+
***
|
|
45
|
+
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NewsTicker } from './news-ticker';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAA","sourcesContent":["/*\n * Copyright © 2017 HatioLab Inc. All rights reserved.\n */\n\nexport { default as NewsTicker } from './news-ticker'\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import './news-ticker-horizontal';
|
|
2
|
+
import './news-ticker-vertical';
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
export default class ThingsNewsTicker extends LitElement {
|
|
5
|
+
textData: string;
|
|
6
|
+
fontFamily: string;
|
|
7
|
+
fontColor: string;
|
|
8
|
+
fontSize: string;
|
|
9
|
+
textAlign: string;
|
|
10
|
+
isReverse: boolean;
|
|
11
|
+
isTextOverflowed: boolean;
|
|
12
|
+
direction?: 'vertical' | 'horizontal';
|
|
13
|
+
duration: number;
|
|
14
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
15
|
+
updated(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import './news-ticker-horizontal';
|
|
6
|
+
import './news-ticker-vertical';
|
|
7
|
+
import { html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
let ThingsNewsTicker = class ThingsNewsTicker extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.textData = '';
|
|
13
|
+
this.fontFamily = '';
|
|
14
|
+
this.fontColor = '';
|
|
15
|
+
this.fontSize = '';
|
|
16
|
+
this.textAlign = '';
|
|
17
|
+
this.isReverse = false;
|
|
18
|
+
this.isTextOverflowed = false;
|
|
19
|
+
this.duration = 30000;
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return html `
|
|
23
|
+
${this.direction == 'vertical'
|
|
24
|
+
? html `
|
|
25
|
+
<ox-news-ticker-vertical
|
|
26
|
+
.duration=${this.duration}
|
|
27
|
+
.isReverse=${this.isReverse}
|
|
28
|
+
.isTextOverflowed=${this.isTextOverflowed}
|
|
29
|
+
.textData=${this.textData}
|
|
30
|
+
></ox-news-ticker-vertical>
|
|
31
|
+
`
|
|
32
|
+
: html `
|
|
33
|
+
<ox-news-ticker-horizontal
|
|
34
|
+
.duration=${this.duration}
|
|
35
|
+
.isReverse=${this.isReverse}
|
|
36
|
+
.isTextOverflowed=${this.isTextOverflowed}
|
|
37
|
+
.textData=${this.textData}
|
|
38
|
+
></ox-news-ticker-horizontal>
|
|
39
|
+
`}
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
updated() {
|
|
43
|
+
this.style.setProperty('--ox-news-ticker-font-family', this.fontFamily);
|
|
44
|
+
this.style.setProperty('--ox-news-ticker-font-size', this.fontSize);
|
|
45
|
+
this.style.setProperty('--ox-news-ticker-font-color', this.fontColor);
|
|
46
|
+
this.style.setProperty('--ox-news-ticker-text-align', this.textAlign);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
__decorate([
|
|
50
|
+
property({ type: String })
|
|
51
|
+
], ThingsNewsTicker.prototype, "textData", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
property({ type: String })
|
|
54
|
+
], ThingsNewsTicker.prototype, "fontFamily", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
property({ type: String })
|
|
57
|
+
], ThingsNewsTicker.prototype, "fontColor", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
property({ type: String })
|
|
60
|
+
], ThingsNewsTicker.prototype, "fontSize", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
property({ type: String })
|
|
63
|
+
], ThingsNewsTicker.prototype, "textAlign", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
property({ type: Boolean })
|
|
66
|
+
], ThingsNewsTicker.prototype, "isReverse", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
property({ type: Boolean })
|
|
69
|
+
], ThingsNewsTicker.prototype, "isTextOverflowed", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
property({ type: String })
|
|
72
|
+
], ThingsNewsTicker.prototype, "direction", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
property({ type: Number })
|
|
75
|
+
], ThingsNewsTicker.prototype, "duration", void 0);
|
|
76
|
+
ThingsNewsTicker = __decorate([
|
|
77
|
+
customElement('ox-news-ticker')
|
|
78
|
+
], ThingsNewsTicker);
|
|
79
|
+
export default ThingsNewsTicker;
|
|
80
|
+
//# sourceMappingURL=news-ticker-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"news-ticker-element.js","sourceRoot":"","sources":["../src/news-ticker-element.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,0BAA0B,CAAA;AACjC,OAAO,wBAAwB,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG3D,IA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vB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAuB;AACrB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA2B;AAC1B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAAkC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAsC;AACrC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AATjC,gBAAgB;IADpC,aAAa,CAAC,gBAAgB,CAAC;GACX,gBAAgB,CAuCpC;eAvCoB,gBAAgB","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './news-ticker-horizontal'\nimport './news-ticker-vertical'\n\nimport { html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\n@customElement('ox-news-ticker')\nexport default class ThingsNewsTicker extends LitElement {\n @property({ type: String }) textData: string = ''\n @property({ type: String }) fontFamily: string = ''\n @property({ type: String }) fontColor: string = ''\n @property({ type: String }) fontSize: string = ''\n @property({ type: String }) textAlign: string = ''\n @property({ type: Boolean }) isReverse: boolean = false\n @property({ type: Boolean }) isTextOverflowed: boolean = false\n @property({ type: String }) direction?: 'vertical' | 'horizontal'\n @property({ type: Number }) duration: number = 30000\n\n render() {\n return html`\n ${this.direction == 'vertical'\n ? html`\n <ox-news-ticker-vertical\n .duration=${this.duration}\n .isReverse=${this.isReverse}\n .isTextOverflowed=${this.isTextOverflowed}\n .textData=${this.textData}\n ></ox-news-ticker-vertical>\n `\n : html`\n <ox-news-ticker-horizontal\n .duration=${this.duration}\n .isReverse=${this.isReverse}\n .isTextOverflowed=${this.isTextOverflowed}\n .textData=${this.textData}\n ></ox-news-ticker-horizontal>\n `}\n `\n }\n\n updated() {\n this.style.setProperty('--ox-news-ticker-font-family', this.fontFamily)\n this.style.setProperty('--ox-news-ticker-font-size', this.fontSize)\n this.style.setProperty('--ox-news-ticker-font-color', this.fontColor)\n this.style.setProperty('--ox-news-ticker-text-align', this.textAlign)\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export default class ThingsNewsTickerHorizontal extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
isReverse: boolean;
|
|
5
|
+
isTextOverflowed?: boolean;
|
|
6
|
+
duration: number;
|
|
7
|
+
textData: string;
|
|
8
|
+
private _anim?;
|
|
9
|
+
animationTargetEl: Element;
|
|
10
|
+
get currentAnimation(): Animation | undefined;
|
|
11
|
+
set currentAnimation(anim: Animation | undefined);
|
|
12
|
+
get textLines(): string[];
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
updated(changes: PropertyValues<this>): void;
|
|
15
|
+
startAnimation(): void;
|
|
16
|
+
stopAnimation(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
6
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
7
|
+
let ThingsNewsTickerHorizontal = class ThingsNewsTickerHorizontal extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.isReverse = false;
|
|
11
|
+
this.duration = 30000;
|
|
12
|
+
this.textData = '';
|
|
13
|
+
}
|
|
14
|
+
get currentAnimation() {
|
|
15
|
+
return this._anim;
|
|
16
|
+
}
|
|
17
|
+
set currentAnimation(anim) {
|
|
18
|
+
this._anim = anim;
|
|
19
|
+
}
|
|
20
|
+
get textLines() {
|
|
21
|
+
return this.textData.split('\n');
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return html `
|
|
25
|
+
<div class="ticker-wrap">
|
|
26
|
+
<div class="ticker">${this.textLines.map(t => html ` <div class="ticker__item">${t}</div> `)}</div>
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
updated(changes) {
|
|
31
|
+
if (changes.has('textData') ||
|
|
32
|
+
changes.has('duration') ||
|
|
33
|
+
changes.has('isReverse') ||
|
|
34
|
+
changes.has('isTextOverflowed')) {
|
|
35
|
+
this.style.setProperty('--ox-news-ticker-wrapper-padding-left', this.isTextOverflowed ? '100%' : '0');
|
|
36
|
+
this.style.setProperty('--ox-news-ticker-container-padding-right', this.isTextOverflowed ? '100%' : '0');
|
|
37
|
+
this.startAnimation();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
startAnimation() {
|
|
41
|
+
this.stopAnimation();
|
|
42
|
+
if (!this.isTextOverflowed)
|
|
43
|
+
return;
|
|
44
|
+
this.currentAnimation = this.animationTargetEl.animate([
|
|
45
|
+
{
|
|
46
|
+
transform: 'translate3d(0, 0, 0)',
|
|
47
|
+
visibility: 'hidden'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
transform: 'translate3d(-100%, 0, 0)',
|
|
51
|
+
visibility: 'visible'
|
|
52
|
+
}
|
|
53
|
+
], {
|
|
54
|
+
duration: this.duration,
|
|
55
|
+
iterations: Infinity,
|
|
56
|
+
direction: this.isReverse ? 'reverse' : 'normal'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
stopAnimation() {
|
|
60
|
+
if (this.currentAnimation) {
|
|
61
|
+
this.currentAnimation.cancel();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
ThingsNewsTickerHorizontal.styles = [
|
|
66
|
+
css `
|
|
67
|
+
:host * {
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host .ticker-wrap {
|
|
72
|
+
position: absolute;
|
|
73
|
+
bottom: 0;
|
|
74
|
+
width: 100%;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
height: 100%;
|
|
77
|
+
background-color: rgba(#000, 0.9);
|
|
78
|
+
padding-left: var(--ox-news-ticker-wrapper-padding-left);
|
|
79
|
+
box-sizing: content-box;
|
|
80
|
+
font-family: var(--ox-news-ticker-font-family);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host .ticker-wrap .ticker {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
min-width: 100%;
|
|
86
|
+
text-align: var(--ox-news-ticker-text-align);
|
|
87
|
+
height: 4rem;
|
|
88
|
+
line-height: 4rem;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
padding-right: var(--ox-news-ticker-container-padding-right);
|
|
91
|
+
box-sizing: content-box;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:host .ticker-wrap .ticker__item {
|
|
95
|
+
display: inline-block;
|
|
96
|
+
font-size: var(--ox-news-ticker-font-size);
|
|
97
|
+
color: var(--ox-news-ticker-font-color);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:host body {
|
|
101
|
+
padding-bottom: 5rem;
|
|
102
|
+
}
|
|
103
|
+
:host h1,
|
|
104
|
+
:host h2,
|
|
105
|
+
:host p {
|
|
106
|
+
padding: 0 5%;
|
|
107
|
+
}
|
|
108
|
+
`
|
|
109
|
+
];
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Boolean })
|
|
112
|
+
], ThingsNewsTickerHorizontal.prototype, "isReverse", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: Boolean })
|
|
115
|
+
], ThingsNewsTickerHorizontal.prototype, "isTextOverflowed", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property({ type: Number })
|
|
118
|
+
], ThingsNewsTickerHorizontal.prototype, "duration", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: String })
|
|
121
|
+
], ThingsNewsTickerHorizontal.prototype, "textData", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
query('.ticker-wrap .ticker')
|
|
124
|
+
], ThingsNewsTickerHorizontal.prototype, "animationTargetEl", void 0);
|
|
125
|
+
ThingsNewsTickerHorizontal = __decorate([
|
|
126
|
+
customElement('ox-news-ticker-horizontal')
|
|
127
|
+
], ThingsNewsTickerHorizontal);
|
|
128
|
+
export default ThingsNewsTickerHorizontal;
|
|
129
|
+
//# sourceMappingURL=news-ticker-horizontal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"news-ticker-horizontal.js","sourceRoot":"","sources":["../src/news-ticker-horizontal.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGlE,IAAqB,0BAA0B,GAA/C,MAAqB,0BAA2B,SAAQ,UAAU;IAAlE;;QA+C+B,cAAS,GAAY,KAAK,CAAA;QAE3B,aAAQ,GAAW,KAAK,CAAA;QACxB,aAAQ,GAAW,EAAE,CAAA;IAqEnD,CAAC;IA/DC,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,IAAI,gBAAgB,CAAC,IAAI;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;8BAEe,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAA,8BAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0CF;CACF,CAAA;AAE4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6DAA2B;AAC1B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oEAA2B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAsB;AAIlB;IAA9B,KAAK,CAAC,sBAAsB,CAAC;qEAA4B;AAtDvC,0BAA0B;IAD9C,aAAa,CAAC,2BAA2B,CAAC;GACtB,0BAA0B,CAuH9C;eAvHoB,0BAA0B","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\n@customElement('ox-news-ticker-horizontal')\nexport default class ThingsNewsTickerHorizontal extends LitElement {\n static styles = [\n css`\n :host * {\n box-sizing: border-box;\n }\n\n :host .ticker-wrap {\n position: absolute;\n bottom: 0;\n width: 100%;\n overflow: hidden;\n height: 100%;\n background-color: rgba(#000, 0.9);\n padding-left: var(--ox-news-ticker-wrapper-padding-left);\n box-sizing: content-box;\n font-family: var(--ox-news-ticker-font-family);\n }\n\n :host .ticker-wrap .ticker {\n display: inline-block;\n min-width: 100%;\n text-align: var(--ox-news-ticker-text-align);\n height: 4rem;\n line-height: 4rem;\n white-space: nowrap;\n padding-right: var(--ox-news-ticker-container-padding-right);\n box-sizing: content-box;\n }\n\n :host .ticker-wrap .ticker__item {\n display: inline-block;\n font-size: var(--ox-news-ticker-font-size);\n color: var(--ox-news-ticker-font-color);\n }\n\n :host body {\n padding-bottom: 5rem;\n }\n :host h1,\n :host h2,\n :host p {\n padding: 0 5%;\n }\n `\n ]\n\n @property({ type: Boolean }) isReverse: boolean = false\n @property({ type: Boolean }) isTextOverflowed?: boolean\n @property({ type: Number }) duration: number = 30000\n @property({ type: String }) textData: string = ''\n\n private _anim?: Animation\n\n @query('.ticker-wrap .ticker') animationTargetEl!: Element\n\n get currentAnimation() {\n return this._anim\n }\n\n set currentAnimation(anim) {\n this._anim = anim\n }\n\n get textLines() {\n return this.textData.split('\\n')\n }\n\n render() {\n return html`\n <div class=\"ticker-wrap\">\n <div class=\"ticker\">${this.textLines.map(t => html` <div class=\"ticker__item\">${t}</div> `)}</div>\n </div>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (\n changes.has('textData') ||\n changes.has('duration') ||\n changes.has('isReverse') ||\n changes.has('isTextOverflowed')\n ) {\n this.style.setProperty('--ox-news-ticker-wrapper-padding-left', this.isTextOverflowed ? '100%' : '0')\n this.style.setProperty('--ox-news-ticker-container-padding-right', this.isTextOverflowed ? '100%' : '0')\n\n this.startAnimation()\n }\n }\n\n startAnimation() {\n this.stopAnimation()\n\n if (!this.isTextOverflowed) return\n\n this.currentAnimation = this.animationTargetEl.animate(\n [\n {\n transform: 'translate3d(0, 0, 0)',\n visibility: 'hidden'\n },\n {\n transform: 'translate3d(-100%, 0, 0)',\n visibility: 'visible'\n }\n ],\n {\n duration: this.duration,\n iterations: Infinity,\n direction: this.isReverse ? 'reverse' : 'normal'\n }\n )\n }\n\n stopAnimation() {\n if (this.currentAnimation) {\n this.currentAnimation.cancel()\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import 'web-animations-js';
|
|
2
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
3
|
+
export default class ThingsNewsTickerVertical extends LitElement {
|
|
4
|
+
static styles: import("lit").CSSResult[];
|
|
5
|
+
isReverse: boolean;
|
|
6
|
+
duration: number;
|
|
7
|
+
textData: string;
|
|
8
|
+
private _anim?;
|
|
9
|
+
animationTargetEl: Element;
|
|
10
|
+
get currentAnimation(): Animation | undefined;
|
|
11
|
+
set currentAnimation(anim: Animation | undefined);
|
|
12
|
+
get textLines(): string[];
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
updated(changes: PropertyValues<this>): void;
|
|
15
|
+
startAnimation(): void;
|
|
16
|
+
stopAnimation(): void;
|
|
17
|
+
createAnimationFrames(): {
|
|
18
|
+
transform: string;
|
|
19
|
+
offset: number;
|
|
20
|
+
easing: string;
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import 'web-animations-js';
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
8
|
+
const CUBIC_BEZIER_EASING = 'cubic-bezier(1, 0, 0.5, 0)';
|
|
9
|
+
let ThingsNewsTickerVertical = class ThingsNewsTickerVertical extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.isReverse = false;
|
|
13
|
+
this.duration = 30000;
|
|
14
|
+
this.textData = '';
|
|
15
|
+
}
|
|
16
|
+
get currentAnimation() {
|
|
17
|
+
return this._anim;
|
|
18
|
+
}
|
|
19
|
+
set currentAnimation(anim) {
|
|
20
|
+
this._anim = anim;
|
|
21
|
+
}
|
|
22
|
+
get textLines() {
|
|
23
|
+
return this.textData.split('\n');
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
return html `
|
|
27
|
+
<div id="news_ticker">
|
|
28
|
+
<ul>
|
|
29
|
+
${this.textLines.map(t => html ` <li><a href="#">${t}</a></li> `)}
|
|
30
|
+
</ul>
|
|
31
|
+
</div>
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
updated(changes) {
|
|
35
|
+
if (changes.has('textData') || changes.has('duration') || changes.has('isReverse')) {
|
|
36
|
+
this.startAnimation();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
startAnimation() {
|
|
40
|
+
this.stopAnimation();
|
|
41
|
+
var frames = this.createAnimationFrames();
|
|
42
|
+
this.currentAnimation = this.animationTargetEl.animate(frames, {
|
|
43
|
+
duration: this.textLines.length * this.duration,
|
|
44
|
+
iterations: Infinity,
|
|
45
|
+
direction: this.isReverse ? 'reverse' : 'normal'
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
stopAnimation() {
|
|
49
|
+
if (this.currentAnimation)
|
|
50
|
+
this.currentAnimation.cancel();
|
|
51
|
+
}
|
|
52
|
+
createAnimationFrames() {
|
|
53
|
+
var textLinesLength = this.textLines.length;
|
|
54
|
+
var frames = this.textLines.map((t, i) => {
|
|
55
|
+
return {
|
|
56
|
+
transform: `translateY(${-(i / textLinesLength) * 100}%)`,
|
|
57
|
+
offset: (1 / textLinesLength) * i,
|
|
58
|
+
easing: CUBIC_BEZIER_EASING
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
frames.push({
|
|
62
|
+
transform: `translateY(0)`,
|
|
63
|
+
offset: 1,
|
|
64
|
+
easing: CUBIC_BEZIER_EASING
|
|
65
|
+
});
|
|
66
|
+
return frames;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
ThingsNewsTickerVertical.styles = [
|
|
70
|
+
css `
|
|
71
|
+
:host {
|
|
72
|
+
display: block;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
height: 100%;
|
|
75
|
+
width: 100%;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
ul {
|
|
80
|
+
margin: 0;
|
|
81
|
+
padding: 0;
|
|
82
|
+
list-style: none;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#news_ticker {
|
|
87
|
+
width: 100%;
|
|
88
|
+
height: 100%;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
position: relative;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
li {
|
|
94
|
+
display: flex;
|
|
95
|
+
height: 100%;
|
|
96
|
+
align-items: center;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
text-align: var(--ox-news-ticker-text-align, left);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#news_ticker a {
|
|
102
|
+
width: 100%;
|
|
103
|
+
line-height: normal;
|
|
104
|
+
color: var(--ox-news-ticker-font-color, black);
|
|
105
|
+
text-decoration: none;
|
|
106
|
+
font-size: var(--ox-news-ticker-font-size, 13px);
|
|
107
|
+
}
|
|
108
|
+
`
|
|
109
|
+
];
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Boolean })
|
|
112
|
+
], ThingsNewsTickerVertical.prototype, "isReverse", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: Number })
|
|
115
|
+
], ThingsNewsTickerVertical.prototype, "duration", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property({ type: String })
|
|
118
|
+
], ThingsNewsTickerVertical.prototype, "textData", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
query('#news_ticker > ul')
|
|
121
|
+
], ThingsNewsTickerVertical.prototype, "animationTargetEl", void 0);
|
|
122
|
+
ThingsNewsTickerVertical = __decorate([
|
|
123
|
+
customElement('ox-news-ticker-vertical')
|
|
124
|
+
], ThingsNewsTickerVertical);
|
|
125
|
+
export default ThingsNewsTickerVertical;
|
|
126
|
+
//# sourceMappingURL=news-ticker-vertical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"news-ticker-vertical.js","sourceRoot":"","sources":["../src/news-ticker-vertical.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,mBAAmB,CAAA;AAE1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,MAAM,mBAA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J,CAAC;IAED,aAAa;QACX,IAAI,IAAI,CAAC,gBAAgB;YAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAA;IAC3D,CAAC;IAED,qBAAqB;QACnB,IAAI,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAA;QAC3C,IAAI,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACvC,OAAO;gBACL,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,GAAG,IAAI;gBACzD,MAAM,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC;gBACjC,MAAM,EAAE,mBAAmB;aAC5B,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,IAAI,CAAC;YACV,SAAS,EAAE,eAAe;YAC1B,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,mBAAmB;SAC5B,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AA/GQ,+BAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCF;CACF,CAAA;AAE4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2DAA2B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAsB;AAIrB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;mEAA4B;AAjDpC,wBAAwB;IAD5C,aAAa,CAAC,yBAAyB,CAAC;GACpB,wBAAwB,CAgH5C;eAhHoB,wBAAwB","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport 'web-animations-js'\n\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nconst CUBIC_BEZIER_EASING = 'cubic-bezier(1, 0, 0.5, 0)'\n\n@customElement('ox-news-ticker-vertical')\nexport default class ThingsNewsTickerVertical extends LitElement {\n static styles = [\n css`\n :host {\n display: block;\n overflow: hidden;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n }\n\n ul {\n margin: 0;\n padding: 0;\n list-style: none;\n white-space: nowrap;\n }\n\n #news_ticker {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n\n li {\n display: flex;\n height: 100%;\n align-items: center;\n overflow: hidden;\n text-align: var(--ox-news-ticker-text-align, left);\n }\n\n #news_ticker a {\n width: 100%;\n line-height: normal;\n color: var(--ox-news-ticker-font-color, black);\n text-decoration: none;\n font-size: var(--ox-news-ticker-font-size, 13px);\n }\n `\n ]\n\n @property({ type: Boolean }) isReverse: boolean = false\n @property({ type: Number }) duration: number = 30000\n @property({ type: String }) textData: string = ''\n\n private _anim?: Animation\n\n @query('#news_ticker > ul') animationTargetEl!: Element\n\n get currentAnimation() {\n return this._anim\n }\n\n set currentAnimation(anim) {\n this._anim = anim\n }\n\n get textLines() {\n return this.textData.split('\\n')\n }\n\n render() {\n return html`\n <div id=\"news_ticker\">\n <ul>\n ${this.textLines.map(t => html` <li><a href=\"#\">${t}</a></li> `)}\n </ul>\n </div>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('textData') || changes.has('duration') || changes.has('isReverse')) {\n this.startAnimation()\n }\n }\n\n startAnimation() {\n this.stopAnimation()\n\n var frames = this.createAnimationFrames()\n this.currentAnimation = this.animationTargetEl.animate(frames, {\n duration: this.textLines.length * this.duration,\n iterations: Infinity,\n direction: this.isReverse ? 'reverse' : 'normal'\n })\n }\n\n stopAnimation() {\n if (this.currentAnimation) this.currentAnimation.cancel()\n }\n\n createAnimationFrames() {\n var textLinesLength = this.textLines.length\n var frames = this.textLines.map((t, i) => {\n return {\n transform: `translateY(${-(i / textLinesLength) * 100}%)`,\n offset: (1 / textLinesLength) * i,\n easing: CUBIC_BEZIER_EASING\n }\n })\n\n frames.push({\n transform: `translateY(0)`,\n offset: 1,\n easing: CUBIC_BEZIER_EASING\n })\n\n return frames\n }\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import './news-ticker-element';
|
|
2
|
+
import { HTMLOverlayElement } from '@hatiolab/things-scene';
|
|
3
|
+
export default class NewsTicker extends HTMLOverlayElement {
|
|
4
|
+
get nature(): {
|
|
5
|
+
mutable: boolean;
|
|
6
|
+
resizable: boolean;
|
|
7
|
+
rotatable: boolean;
|
|
8
|
+
properties: ({
|
|
9
|
+
type: string;
|
|
10
|
+
label: string;
|
|
11
|
+
name: string;
|
|
12
|
+
property: {
|
|
13
|
+
options: {
|
|
14
|
+
display: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
placeholder?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
type: string;
|
|
21
|
+
label: string;
|
|
22
|
+
name: string;
|
|
23
|
+
property?: undefined;
|
|
24
|
+
placeholder?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
type: string;
|
|
27
|
+
label: string;
|
|
28
|
+
name: string;
|
|
29
|
+
placeholder: string;
|
|
30
|
+
property?: undefined;
|
|
31
|
+
})[];
|
|
32
|
+
help: string;
|
|
33
|
+
};
|
|
34
|
+
get hasTextProperty(): boolean;
|
|
35
|
+
get tagName(): string;
|
|
36
|
+
createElement(): void;
|
|
37
|
+
setElementProperties(element: HTMLElement): void;
|
|
38
|
+
get isTextOverflowed(): boolean;
|
|
39
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2017 HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './news-ticker-element';
|
|
5
|
+
import { Component, error, HTMLOverlayElement } from '@hatiolab/things-scene';
|
|
6
|
+
const NATURE = {
|
|
7
|
+
mutable: false,
|
|
8
|
+
resizable: true,
|
|
9
|
+
rotatable: true,
|
|
10
|
+
properties: [
|
|
11
|
+
{
|
|
12
|
+
type: 'select',
|
|
13
|
+
label: 'direction',
|
|
14
|
+
name: 'direction',
|
|
15
|
+
property: {
|
|
16
|
+
options: [
|
|
17
|
+
{
|
|
18
|
+
display: 'horizontal',
|
|
19
|
+
value: 'horizontal'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
display: 'vertical',
|
|
23
|
+
value: 'vertical'
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'checkbox',
|
|
30
|
+
label: 'reverse',
|
|
31
|
+
name: 'reverse'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'number',
|
|
35
|
+
label: 'duration',
|
|
36
|
+
name: 'duration',
|
|
37
|
+
placeholder: 'seconds'
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
help: 'scene/component/news-ticker'
|
|
41
|
+
};
|
|
42
|
+
export default class NewsTicker extends HTMLOverlayElement {
|
|
43
|
+
get nature() {
|
|
44
|
+
return NATURE;
|
|
45
|
+
}
|
|
46
|
+
get hasTextProperty() {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
get tagName() {
|
|
50
|
+
return 'ox-news-ticker';
|
|
51
|
+
}
|
|
52
|
+
createElement() {
|
|
53
|
+
super.createElement();
|
|
54
|
+
this.setState('text', '#{data}');
|
|
55
|
+
var element = this.element;
|
|
56
|
+
element.style.overflow = 'hidden';
|
|
57
|
+
}
|
|
58
|
+
/* component.property => element.property */
|
|
59
|
+
setElementProperties(element) {
|
|
60
|
+
try {
|
|
61
|
+
var { direction = 'horizontal', reverse, textAlign, fontColor = 'black', fontSize = 13, font, duration = 30 } = this.state;
|
|
62
|
+
var text = this.text;
|
|
63
|
+
var isReverse = reverse;
|
|
64
|
+
var isTextOverflowed = this.isTextOverflowed;
|
|
65
|
+
var newsTicker = element;
|
|
66
|
+
newsTicker.direction = direction;
|
|
67
|
+
newsTicker.duration = duration * 1000;
|
|
68
|
+
newsTicker.fontColor = fontColor;
|
|
69
|
+
newsTicker.fontFamily = font;
|
|
70
|
+
newsTicker.fontSize = `${fontSize}px`;
|
|
71
|
+
newsTicker.textAlign = textAlign;
|
|
72
|
+
newsTicker.isReverse = isReverse;
|
|
73
|
+
newsTicker.isTextOverflowed = isTextOverflowed;
|
|
74
|
+
newsTicker.textData = text;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
error(e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
get isTextOverflowed() {
|
|
81
|
+
var { width } = this.bounds;
|
|
82
|
+
var span = document.createElement('span');
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
span.style.font = this.font;
|
|
85
|
+
span.style.position = 'fixed';
|
|
86
|
+
span.style.left = '-100%';
|
|
87
|
+
span.style.visibility = 'none';
|
|
88
|
+
span.textContent = this.text;
|
|
89
|
+
document.body.appendChild(span);
|
|
90
|
+
var textBounds = span.getBoundingClientRect();
|
|
91
|
+
var isOverflowed = width < textBounds.width;
|
|
92
|
+
document.body.removeChild(span);
|
|
93
|
+
return isOverflowed;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
Component.register('news-ticker', NewsTicker);
|
|
97
|
+
//# sourceMappingURL=news-ticker.js.map
|