@24i/bigscreen-sdk 1.0.4-alpha.2106 → 1.0.4-alpha.2109

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.4-alpha.2106",
3
+ "version": "1.0.4-alpha.2109",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,7 +40,7 @@ If you use it in combination with *JSAnimations* then you will need only static
40
40
 
41
41
  ## JSAnimations
42
42
  Create your own instance in your component. To start the animation you call start and pass callback;
43
- ```javascript
43
+ ```ts
44
44
  animations = new JSAnimations();
45
45
  ...
46
46
  animations.start(from, to, timeInMs, AnimationUtils.ease).onFrame(this.onFrame);
@@ -50,6 +50,17 @@ animations.start(from, to, timeInMs, AnimationUtils.ease).onFrame(this.onFrame);
50
50
  If you start another animation (with the same instance) before the previous ends.
51
51
  Then the from is not what you passed but current position of running animation.
52
52
 
53
+ ## Frame callback
54
+ Frame callback is called each time animation progresses. It has two parameters.
55
+ Parameter `value` is the current value of the animation between `from` and `to`.
56
+ Parameter `percentage` is optional and it is the percentual progress of the animation
57
+ between 0 and 1. The value is not linear, it is based on the ease function used in
58
+ the animation.
59
+
60
+ ```ts
61
+ frameCallback = (value: number, percentage?: number) => void;
62
+ ```
63
+
53
64
  ## Timing Example
54
65
  Time | Call | Result
55
66
  ---|---|---
@@ -63,7 +74,7 @@ To the root of your package add this file:
63
74
  __mocks__/@24i/smartapps-bigscreenen-animations.ts
64
75
  ```
65
76
  with this content
66
- ```js
77
+ ```ts
67
78
  export { AnimationUtils } from '@24i/bigscreen-sdk/animations';
68
79
  export { JSAnimations } from '@24i/bigscreen-sdk/animations/mock';
69
80
 
@@ -162,16 +162,22 @@ export class AnimationUtils {
162
162
  static easeInOutBack: EasingType = [0.68, -0.55, 0.265, 1.55];
163
163
 
164
164
  /**
165
- * Returns value at given percentage
165
+ * Returns value at given time percentage with percentage in easing function
166
166
  * @param {number} min - minimal value
167
167
  * @param {number} max - maximal value
168
168
  * @param {number} percentage - percentage of time
169
169
  * @param {EasingType} easingFunction - easing function for calculation
170
- * @returns {number} calculated value
171
- */
172
- xInTime(min: number, max: number, percentage: number, easingFunction: EasingType): number {
173
- const percentageInTime = this.getPercentageAt(percentage, easingFunction);
174
- return this.linearInterpolation(min, max, percentageInTime);
170
+ * @returns {Object} calculated value and percentual value in easing
171
+ */
172
+ xInTime(min: number, max: number, percentage: number, easingFunction: EasingType): {
173
+ value: number,
174
+ percentage: number,
175
+ } {
176
+ const percentageInEasing = this.getPercentageAt(percentage, easingFunction);
177
+ return {
178
+ value: this.linearInterpolation(min, max, percentageInEasing),
179
+ percentage: percentageInEasing,
180
+ };
175
181
  }
176
182
 
177
183
  /**
@@ -71,10 +71,12 @@ export class JSAnimations {
71
71
  easingFunction: EasingType = AnimationUtils.ease;
72
72
 
73
73
  /**
74
- * @member {FrameCallback} frameCallback - callback being called on evry frame
74
+ * @member {FrameCallback} frameCallback - callback being called on every frame
75
75
  * @private
76
+ * @param {number} value - current value of the animation
77
+ * @param {number} [percentage] - current progress of the animation in percents
76
78
  */
77
- frameCallback?: (value: number) => void;
79
+ frameCallback?: (value: number, percentage?: number) => void;
78
80
 
79
81
  /**
80
82
  * Starts animation
@@ -115,7 +117,7 @@ export class JSAnimations {
115
117
  this.animationRunning = false;
116
118
  }
117
119
  const timePercentage = this.currentTime / this.animationTime;
118
- const value = this.animations.xInTime(
120
+ const { value, percentage } = this.animations.xInTime(
119
121
  this.from,
120
122
  this.to,
121
123
  timePercentage,
@@ -123,7 +125,7 @@ export class JSAnimations {
123
125
  );
124
126
  this.currentPosition = value;
125
127
  if (this.frameCallback) {
126
- this.frameCallback(value);
128
+ this.frameCallback(value, percentage);
127
129
  }
128
130
  if (this.animationRunning) {
129
131
  this.animationFrameID = window.requestAnimationFrame(this.frame);
@@ -134,7 +136,7 @@ export class JSAnimations {
134
136
  * Frame callback handler
135
137
  * @param {FrameCallback} callback - callback to run on every animation frame
136
138
  */
137
- onFrame(callback: (value: number) => void) {
139
+ onFrame(callback: (value: number, percentage?: number) => void) {
138
140
  if (typeof callback === 'function') {
139
141
  this.frameCallback = callback;
140
142
  }
@@ -53,7 +53,7 @@ export class EnvironmentListItem extends Component<Props> implements Item<ItemDa
53
53
  trimRows() {
54
54
  const { leadingEllipses } = this.props;
55
55
  if (leadingEllipses) {
56
- trimWithLeadingEllipsis(this.labelRef.current!);
56
+ trimWithLeadingEllipsis(this.labelRef.current!, 2);
57
57
  }
58
58
  }
59
59
 
@@ -43,7 +43,11 @@
43
43
  padding-right: $environment-config-name-padding-right;
44
44
  line-height: $environment-config-name-height;
45
45
  height: $environment-config-name-height;
46
+ max-width: $environment-config-name-width;
47
+ text-align: left;
46
48
  white-space: nowrap;
49
+ overflow: hidden;
50
+ text-overflow: ellipsis;
47
51
  }
48
52
  }
49
53
 
@@ -9,6 +9,7 @@ $environment-config-name-font-size: 22px;
9
9
  $environment-config-name-padding-left: 12px;
10
10
  $environment-config-name-padding-right: 7px;
11
11
  $environment-config-name-height: 33px;
12
+ $environment-config-name-width: 400px;
12
13
 
13
14
  $environment-list-width: 479px;
14
15
 
@@ -9,6 +9,7 @@ $environment-config-name-font-size: 15px;
9
9
  $environment-config-name-padding-left: 8px;
10
10
  $environment-config-name-padding-right: 5px;
11
11
  $environment-config-name-height: 22px;
12
+ $environment-config-name-width: 200px;
12
13
 
13
14
  $environment-list-width: 319px;
14
15
 
@@ -1,12 +1,12 @@
1
1
  const ELLIPSIS = '...';
2
2
 
3
- export const trimWithLeadingEllipsis = (row: HTMLSpanElement) => {
3
+ export const trimWithLeadingEllipsis = (row: HTMLSpanElement, requestedNumberOfLines: number) => {
4
4
  if (row && row.textContent != null) {
5
5
  row.style.visibility = 'hidden';
6
6
  const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
7
7
  const lineHeight = parseInt(lineHeightString, 10);
8
8
  let numberOfLines = row.offsetHeight / lineHeight;
9
- if (numberOfLines >= 2) {
9
+ if (numberOfLines > requestedNumberOfLines) {
10
10
  const originalTextContent = row.textContent;
11
11
  row.textContent = ELLIPSIS;
12
12
  let stringBuffer = '';
@@ -17,7 +17,7 @@ export const trimWithLeadingEllipsis = (row: HTMLSpanElement) => {
17
17
  row.textContent = `${ELLIPSIS}${stringBuffer}`;
18
18
  currentPosition -= 1;
19
19
  numberOfLines = Math.floor(row.offsetHeight / lineHeight);
20
- } while (numberOfLines < 2 && currentPosition >= 0);
20
+ } while (numberOfLines <= requestedNumberOfLines && currentPosition >= 0);
21
21
  row.textContent = `${ELLIPSIS}${stringBuffer.substring(1)}`;
22
22
  }
23
23
  row.style.visibility = '';