@24i/bigscreen-sdk 1.0.42 → 1.0.43-alpha.2726

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.42",
3
+ "version": "1.0.43-alpha.2726",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -74,7 +74,7 @@ export class GoogleAnalytics implements AnalyticsClient {
74
74
  params.cid = generateUuid();
75
75
  await Storage.setItem(GA_CLIENT_ID, params.cid);
76
76
  }
77
- this.firstVisit = !(await Storage.getItem(GA_FIRST_VISIT)) ?? true;
77
+ this.firstVisit = !(await Storage.getItem(GA_FIRST_VISIT));
78
78
  if (this.firstVisit) {
79
79
  await Storage.setItem(GA_FIRST_VISIT, '0');
80
80
  }
@@ -298,15 +298,15 @@ export class UnifiedGridController<T> implements IUnifiedGridController<T> {
298
298
  const { grid } = this;
299
299
  const base = grid.base.current!;
300
300
  const targetScrollIndex = this.itemIndexToScrollIndex(dataIndex);
301
- if (targetScrollIndex > this.scrollIndex) {
302
- this.adjustGroupsOffsetsForward(targetScrollIndex);
303
- } else if (targetScrollIndex < this.scrollIndex) {
304
- this.adjustGroupsOffsetsBackward(targetScrollIndex);
305
- }
306
301
  if (targetScrollIndex !== this.scrollIndex) {
307
- this.scroll(targetScrollIndex, animate);
302
+ const backwards = targetScrollIndex < this.scrollIndex;
303
+ const lastScrollIndex = this.scrollIndex;
304
+ const scrollToIndex = Math.abs(targetScrollIndex - this.scrollIndex);
305
+ for (let i = 1; i <= scrollToIndex; i++) {
306
+ this.scroll(backwards ? lastScrollIndex - i : lastScrollIndex + i, animate);
307
+ }
308
+ base.index = dataIndex;
308
309
  }
309
- base.index = dataIndex;
310
310
  this.focusCurrentItem();
311
311
  base.mrcuRef.current?.handleArrowState();
312
312
  }
@@ -127,34 +127,34 @@ export class BasicList<T extends Item<U>, U>
127
127
  this.controller.focusCurrentItem(options);
128
128
  }
129
129
 
130
- scrollTo(index: number) {
130
+ scrollTo(index: number, animate?: boolean) {
131
131
  const list = this.base.current!;
132
132
  const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
133
133
  if (list.index === safeIndex) return;
134
134
  if (list.index < safeIndex) {
135
- this.scrollToForward(safeIndex);
135
+ this.scrollToForward(safeIndex, animate);
136
136
  } else {
137
- this.scrollToBackward(safeIndex);
137
+ this.scrollToBackward(safeIndex, animate);
138
138
  }
139
139
  }
140
140
 
141
- private scrollToForward(index: number) {
141
+ private scrollToForward(index: number, animate?: boolean) {
142
142
  const { visibleItems } = this.props;
143
143
  const list = this.base.current!;
144
144
  list.index = index;
145
145
  const scrollTarget = list.index - visibleItems + VISIBLE_ITEMS_OFFSET;
146
146
  if (scrollTarget > this.controller.scrollIndex) {
147
- this.controller.scroll(scrollTarget);
147
+ this.controller.scroll(scrollTarget, animate);
148
148
  }
149
149
  }
150
150
 
151
- private scrollToBackward(index: number) {
151
+ private scrollToBackward(index: number, animate?: boolean) {
152
152
  const { firstScrollStep, scrollStep } = this.props;
153
153
  const list = this.base.current!;
154
154
  list.index = index;
155
155
  const offset = firstScrollStep < scrollStep ? 1 : 0;
156
156
  if (list.index - offset < this.controller.scrollIndex) {
157
- this.controller.scroll(list.index);
157
+ this.controller.scroll(list.index, animate);
158
158
  }
159
159
  }
160
160
 
@@ -90,12 +90,12 @@ export class CenteredList<T extends Item<U>, U>
90
90
  this.controller.focusCurrentItem(options);
91
91
  }
92
92
 
93
- scrollTo(index: number) {
93
+ scrollTo(index: number, animate?: boolean) {
94
94
  const list = this.base.current!;
95
95
  const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
96
96
  if (list.index === safeIndex) return;
97
97
  list.index = safeIndex;
98
- this.controller.scroll(list.index);
98
+ this.controller.scroll(list.index, animate);
99
99
  }
100
100
 
101
101
  render() {
@@ -120,18 +120,18 @@ export class EdgeOffsetList<T extends Item<U>, U>
120
120
  this.controller.focusCurrentItem(options);
121
121
  }
122
122
 
123
- scrollTo(index: number) {
123
+ scrollTo(index: number, animate?: boolean) {
124
124
  const list = this.base.current!;
125
125
  const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
126
126
  if (list.index === safeIndex) return;
127
127
  if (list.index < safeIndex) {
128
- this.scrollToForward(safeIndex);
128
+ this.scrollToForward(safeIndex, animate);
129
129
  } else {
130
- this.scrollToBackward(safeIndex);
130
+ this.scrollToBackward(safeIndex, animate);
131
131
  }
132
132
  }
133
133
 
134
- private scrollToForward(index: number) {
134
+ private scrollToForward(index: number, animate?: boolean) {
135
135
  const { visibleItems, edgeOffset } = this.props;
136
136
  const list = this.base.current!;
137
137
  list.index = index;
@@ -140,16 +140,16 @@ export class EdgeOffsetList<T extends Item<U>, U>
140
140
  : edgeOffset + list.index - list.data.length - 1;
141
141
  const scrollTarget = list.index - visibleItems + offset + VISIBLE_ITEMS_OFFSET;
142
142
  if (scrollTarget > this.controller.scrollIndex) {
143
- this.controller.scroll(scrollTarget);
143
+ this.controller.scroll(scrollTarget, animate);
144
144
  }
145
145
  }
146
146
 
147
- private scrollToBackward(index: number) {
147
+ private scrollToBackward(index: number, animate?: boolean) {
148
148
  const { edgeOffset } = this.props;
149
149
  const list = this.base.current!;
150
150
  list.index = index;
151
151
  if (list.index <= this.controller.scrollIndex) {
152
- this.controller.scroll(list.index < edgeOffset ? 0 : list.index - edgeOffset);
152
+ this.controller.scroll(list.index < edgeOffset ? 0 : list.index - edgeOffset, animate);
153
153
  }
154
154
  }
155
155
 
@@ -96,12 +96,12 @@ export class FirstOnlyList<T extends Item<U>, U>
96
96
  this.controller.focusCurrentItem(options);
97
97
  }
98
98
 
99
- scrollTo(index: number) {
99
+ scrollTo(index: number, animate?: boolean) {
100
100
  const list = this.base.current!;
101
101
  const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
102
102
  if (list.index === safeIndex) return;
103
103
  list.index = safeIndex;
104
- this.controller.scroll(list.index);
104
+ this.controller.scroll(list.index, animate);
105
105
  }
106
106
 
107
107
  render() {
@@ -106,12 +106,12 @@ export class FirstOnlyVariedList<T extends Item<U>, U> extends Component<Props<T
106
106
  this.controller.focusCurrentItem(options);
107
107
  }
108
108
 
109
- scrollTo(index: number) {
109
+ scrollTo(index: number, animate?: boolean) {
110
110
  const list = this.base.current!;
111
111
  const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
112
112
  if (list.index === safeIndex) return;
113
113
  list.index = safeIndex;
114
- this.controller.scroll(0);
114
+ this.controller.scroll(0, animate);
115
115
  }
116
116
 
117
117
  render() {
@@ -99,12 +99,12 @@ export class FixedToEndList<T extends Item<U>, U>
99
99
  this.controller.focusCurrentItem(options);
100
100
  }
101
101
 
102
- scrollTo(index: number) {
102
+ scrollTo(index: number, animate?: boolean) {
103
103
  const list = this.base.current!;
104
104
  const safeIndex = Math.max(0, Math.min(index, list.data.length - 1));
105
105
  if (list.index === safeIndex) return;
106
106
  list.index = safeIndex;
107
- this.controller.scroll(list.index);
107
+ this.controller.scroll(list.index, animate);
108
108
  }
109
109
 
110
110
  render() {
@@ -12,7 +12,7 @@ export interface List<
12
12
  controller: UnifiedListController<U>,
13
13
  appendData(data: U[]): void,
14
14
  prependData(data: U[]): void,
15
- scrollTo(index: number): void,
15
+ scrollTo(index: number, animate?: boolean): void,
16
16
  }
17
17
 
18
18
  export interface VariedList<
@@ -22,7 +22,7 @@ export interface VariedList<
22
22
  controller: UnifiedVariedListController<U>,
23
23
  appendData(data: U[]): void,
24
24
  prependData(data: U[]): void,
25
- scrollTo(index: number): void,
25
+ scrollTo(index: number, animate?: boolean): void,
26
26
  }
27
27
 
28
28
  export interface ListComponent<