@24i/bigscreen-sdk 1.0.2-alpha.2071 → 1.0.2-alpha.2074
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 +1 -1
- package/packages/list/src/Base/Base.tsx +16 -5
- package/packages/list/src/Base/MouseNavigation/MouseNavigation.tsx +58 -0
- package/packages/list/src/Base/MouseNavigation/MouseNavigationFallback.ts +4 -0
- package/packages/list/src/Base/MouseNavigation/index.tizen.tv.ts +1 -0
- package/packages/list/src/Base/MouseNavigation/index.ts +1 -0
- package/packages/list/src/Base/MouseNavigation/index.webos.tv.ts +1 -0
- package/packages/list/src/Base/MouseNavigation/index.webtv.ts +1 -0
- package/packages/list/src/Base/interface.ts +39 -0
- package/packages/mouse-navigation/src/MouseNavigation.tsx +2 -2
- package/packages/list/src/Base/Base.mouse.tsx +0 -28
- package/packages/list/src/Base/index.tizen.tv.ts +0 -1
- package/packages/list/src/Base/index.webos.tv.ts +0 -1
- package/packages/list/src/Base/index.webtv.ts +0 -1
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRef, Component, Reference, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { MouseNavigation } from '@24i/bigscreen-sdk/mouse-navigation';
|
|
3
2
|
import { device } from '@24i/bigscreen-sdk/device';
|
|
4
3
|
import { Scroller } from '@24i/bigscreen-sdk/scroller';
|
|
5
4
|
import { forEach } from '@24i/bigscreen-sdk/perf-utils/array';
|
|
@@ -10,8 +9,12 @@ import {
|
|
|
10
9
|
ICounter,
|
|
11
10
|
createTimeout,
|
|
12
11
|
} from '@24i/bigscreen-sdk/utils';
|
|
12
|
+
import { MouseNavigation } from './MouseNavigation';
|
|
13
13
|
import { FastFocusingOptimizer } from '../FastFocusingOptimizer/FastFocusingOptimizer';
|
|
14
14
|
import { BasicProps, Item } from '../types';
|
|
15
|
+
import {
|
|
16
|
+
MouseNavigation as IMouseNavigation,
|
|
17
|
+
} from './interface';
|
|
15
18
|
|
|
16
19
|
export type Props<T extends Item<U>, U> = BasicProps<T, U> & {
|
|
17
20
|
forward: () => boolean,
|
|
@@ -21,7 +24,6 @@ export type Props<T extends Item<U>, U> = BasicProps<T, U> & {
|
|
|
21
24
|
shouldShowMrcuForward?: () => boolean,
|
|
22
25
|
shouldShowMrcuBackward?: () => boolean,
|
|
23
26
|
adjustFocusFromTarget?: (itemRefIndex: number) => void,
|
|
24
|
-
mrcuRef?: Reference<MouseNavigation>;
|
|
25
27
|
limit?: number,
|
|
26
28
|
shouldApplySlowdown?: () => boolean,
|
|
27
29
|
};
|
|
@@ -45,6 +47,8 @@ export class ListBase<T extends Item<U>, U>
|
|
|
45
47
|
|
|
46
48
|
scrollerDom = createRef<HTMLDivElement>();
|
|
47
49
|
|
|
50
|
+
mrcuRef = createRef<IMouseNavigation>();
|
|
51
|
+
|
|
48
52
|
itemRefs: Reference<T>[] = [];
|
|
49
53
|
|
|
50
54
|
index = 0;
|
|
@@ -123,15 +127,16 @@ export class ListBase<T extends Item<U>, U>
|
|
|
123
127
|
|
|
124
128
|
onWheel = (event: WheelEvent) => {
|
|
125
129
|
const {
|
|
126
|
-
forward, backward,
|
|
130
|
+
horizontal, forward, backward, shouldApplySlowdown,
|
|
127
131
|
} = this.props;
|
|
128
132
|
let processed;
|
|
133
|
+
if (horizontal) return;
|
|
129
134
|
if (event.deltaY > 0) processed = shouldApplySlowdown() || forward();
|
|
130
135
|
else if (event.deltaY < 0) processed = shouldApplySlowdown() || backward();
|
|
131
136
|
if (processed) {
|
|
132
137
|
stopEvent(event);
|
|
133
138
|
this.fastScrollingCounter?.add();
|
|
134
|
-
mrcuRef?.current?.handleArrowState();
|
|
139
|
+
this.mrcuRef?.current?.handleArrowState();
|
|
135
140
|
this.fakeWheelStop();
|
|
136
141
|
} else if (processed === false) {
|
|
137
142
|
this.fastFocusingOptimizer.stop();
|
|
@@ -348,7 +353,13 @@ export class ListBase<T extends Item<U>, U>
|
|
|
348
353
|
onKeyDown={this.onKeyDown}
|
|
349
354
|
horizontal={horizontal}
|
|
350
355
|
>
|
|
351
|
-
{this.renderData()}
|
|
356
|
+
<>{this.renderData()}</>
|
|
357
|
+
<MouseNavigation
|
|
358
|
+
// @ts-ignore - needed to convert fallback (false) to interface
|
|
359
|
+
ref={this.mrcuRef}
|
|
360
|
+
getMountingPoint={() => this.scroller.current!.wrapRef}
|
|
361
|
+
{...this.props}
|
|
362
|
+
/>
|
|
352
363
|
</Scroller>
|
|
353
364
|
);
|
|
354
365
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Component, createRef } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
+
import { MouseNavigation as MouseNavigationBase } from '@24i/bigscreen-sdk/mouse-navigation';
|
|
3
|
+
import { device } from '@24i/bigscreen-sdk/device';
|
|
4
|
+
import {
|
|
5
|
+
MouseNavigationProps as Props,
|
|
6
|
+
MouseNavigation as IMouseNavigation,
|
|
7
|
+
} from '../interface';
|
|
8
|
+
|
|
9
|
+
export class MouseNavigation extends Component<Props> implements IMouseNavigation {
|
|
10
|
+
private readonly div = createRef<HTMLDivElement>();
|
|
11
|
+
|
|
12
|
+
private readonly base = createRef<MouseNavigationBase>();
|
|
13
|
+
|
|
14
|
+
componentDidMount() {
|
|
15
|
+
if (device.isMouseUsed()) {
|
|
16
|
+
this.renderArrows();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
handleArrowState() {
|
|
21
|
+
this.base?.current?.handleArrowState();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
renderArrows() {
|
|
25
|
+
const {
|
|
26
|
+
horizontal,
|
|
27
|
+
forward,
|
|
28
|
+
backward,
|
|
29
|
+
shouldShowMrcuForward,
|
|
30
|
+
shouldShowMrcuBackward,
|
|
31
|
+
getMountingPoint,
|
|
32
|
+
} = this.props;
|
|
33
|
+
|
|
34
|
+
const direction = horizontal ? 'horizontal' : 'vertical';
|
|
35
|
+
|
|
36
|
+
this.appendMount(
|
|
37
|
+
<div ref={this.div} className="mouse-navigation">
|
|
38
|
+
<MouseNavigationBase
|
|
39
|
+
// @ts-ignore - needed to convert fallback (false) to interface
|
|
40
|
+
ref={this.base}
|
|
41
|
+
getMountingPoint={() => this.div}
|
|
42
|
+
direction={direction}
|
|
43
|
+
forward={forward}
|
|
44
|
+
backward={backward}
|
|
45
|
+
shouldShowMrcuForward={shouldShowMrcuForward}
|
|
46
|
+
shouldShowMrcuBackward={shouldShowMrcuBackward}
|
|
47
|
+
>
|
|
48
|
+
{null as unknown as JSX.Element}
|
|
49
|
+
</MouseNavigationBase>
|
|
50
|
+
</div>,
|
|
51
|
+
getMountingPoint(),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
render() {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MouseNavigation } from './MouseNavigation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MouseNavigation } from './MouseNavigationFallback';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MouseNavigation } from './MouseNavigation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MouseNavigation } from './MouseNavigation';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Reference, Component } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
+
|
|
3
|
+
export type MouseNavigationProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Function to call on the press of the right arrow.
|
|
6
|
+
*/
|
|
7
|
+
forward(): boolean,
|
|
8
|
+
/**
|
|
9
|
+
* Function to call on the press of the left arrow.
|
|
10
|
+
*/
|
|
11
|
+
backward(): boolean,
|
|
12
|
+
/**
|
|
13
|
+
* Function which determines whether to show the forward arrow.
|
|
14
|
+
*/
|
|
15
|
+
shouldShowMrcuForward?(): boolean,
|
|
16
|
+
/**
|
|
17
|
+
* Function which determines whether to show the backward arrow.
|
|
18
|
+
*/
|
|
19
|
+
shouldShowMrcuBackward?(): boolean,
|
|
20
|
+
/**
|
|
21
|
+
* Returns a reference to the element where your `children` should be rendered.
|
|
22
|
+
*/
|
|
23
|
+
getMountingPoint(): Reference<HTMLElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Property determines whether navigation is horizontal.
|
|
26
|
+
*/
|
|
27
|
+
horizontal?: boolean,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export interface MouseNavigation extends Component<MouseNavigationProps> {
|
|
31
|
+
/**
|
|
32
|
+
* Function to disable showing an arrow in the given direction.
|
|
33
|
+
*/
|
|
34
|
+
handleArrowState(): void,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface MouseNavigationComponent {
|
|
38
|
+
new (props: MouseNavigationProps): MouseNavigation,
|
|
39
|
+
}
|
|
@@ -8,8 +8,8 @@ type Props = {
|
|
|
8
8
|
children: JSX.Element;
|
|
9
9
|
getMountingPoint: () => Reference<HTMLElement>;
|
|
10
10
|
direction: Direction;
|
|
11
|
-
forward: () =>
|
|
12
|
-
backward: () =>
|
|
11
|
+
forward: () => any;
|
|
12
|
+
backward: () => any;
|
|
13
13
|
shouldShowMrcuForward?: () => boolean;
|
|
14
14
|
shouldShowMrcuBackward?: () => boolean;
|
|
15
15
|
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createRef, forwardRef, Reference } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { MouseNavigation } from '@24i/bigscreen-sdk/mouse-navigation';
|
|
3
|
-
import { ListBase as Base, Props as ListProps } from './Base';
|
|
4
|
-
import { Item } from '../types';
|
|
5
|
-
|
|
6
|
-
export const ListBase = forwardRef(<T extends Item<U>, U>(props: ListProps<T, U>,
|
|
7
|
-
listRef: Reference<Base<T, U>>,
|
|
8
|
-
) => {
|
|
9
|
-
const direction = props.horizontal ? 'horizontal' : 'vertical';
|
|
10
|
-
const mrcuRef = createRef<MouseNavigation>();
|
|
11
|
-
return (
|
|
12
|
-
<MouseNavigation
|
|
13
|
-
getMountingPoint={() => listRef.current!.scroller.current!.wrapRef}
|
|
14
|
-
direction={direction}
|
|
15
|
-
forward={props.mrcuForward || props.forward}
|
|
16
|
-
backward={props.mrcuBackward || props.backward}
|
|
17
|
-
shouldShowMrcuForward={props.shouldShowMrcuForward}
|
|
18
|
-
shouldShowMrcuBackward={props.shouldShowMrcuBackward}
|
|
19
|
-
ref={mrcuRef}
|
|
20
|
-
>
|
|
21
|
-
<Base
|
|
22
|
-
{...props}
|
|
23
|
-
mrcuRef={mrcuRef}
|
|
24
|
-
ref={listRef}
|
|
25
|
-
/>
|
|
26
|
-
</MouseNavigation>
|
|
27
|
-
);
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ListBase } from './Base.mouse';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ListBase } from './Base.mouse';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ListBase } from './Base.mouse';
|