vevet 3.2.2 → 3.3.0
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/lib/cjs/components/AnimationFrame/index.js +1 -1
- package/lib/cjs/components/Marquee/index.js +262 -0
- package/lib/cjs/components/Marquee/index.js.map +1 -0
- package/lib/cjs/components/Marquee/types.js +3 -0
- package/lib/cjs/components/Marquee/types.js.map +1 -0
- package/lib/cjs/components/ScrollBar/Bar/index.js +2 -2
- package/lib/cjs/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/utils/listeners/onResize.js +1 -1
- package/lib/cjs/utils/listeners/onResize.js.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/components/AnimationFrame/index.js +1 -1
- package/lib/esm/components/Marquee/index.js +216 -0
- package/lib/esm/components/Marquee/index.js.map +1 -0
- package/lib/esm/components/Marquee/types.js +2 -0
- package/lib/esm/components/Marquee/types.js.map +1 -0
- package/lib/esm/components/ScrollBar/Bar/index.js +2 -2
- package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/esm/components/index.js +1 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/utils/listeners/onResize.js +1 -1
- package/lib/esm/utils/listeners/onResize.js.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/components/AnimationFrame/types.d.ts +1 -1
- package/lib/types/components/Marquee/index.d.ts +66 -0
- package/lib/types/components/Marquee/index.d.ts.map +1 -0
- package/lib/types/components/Marquee/types.d.ts +53 -0
- package/lib/types/components/Marquee/types.d.ts.map +1 -0
- package/lib/types/components/index.d.ts +1 -0
- package/lib/types/components/index.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -1
- package/src/components/AnimationFrame/index.ts +1 -1
- package/src/components/AnimationFrame/types.ts +1 -1
- package/src/components/Marquee/index.ts +319 -0
- package/src/components/Marquee/stories/index.stories.tsx +27 -0
- package/src/components/Marquee/stories/index.tsx +69 -0
- package/src/components/Marquee/types.ts +55 -0
- package/src/components/ScrollBar/Bar/index.ts +3 -3
- package/src/components/index.ts +1 -0
- package/src/utils/listeners/onResize.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { FC, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Marquee, NMarquee } from '..';
|
|
3
|
+
|
|
4
|
+
interface IProps extends NMarquee.IChangeableProps {}
|
|
5
|
+
|
|
6
|
+
export const Component: FC<IProps> = ({
|
|
7
|
+
speed,
|
|
8
|
+
isEnabled,
|
|
9
|
+
pauseOnHover,
|
|
10
|
+
prependWhitespace,
|
|
11
|
+
isFpsNormalized,
|
|
12
|
+
}) => {
|
|
13
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
14
|
+
|
|
15
|
+
const [width, setWidth] = useState(400);
|
|
16
|
+
const [marquee, setMarquee] = useState<Marquee | undefined>();
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!ref.current) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const instance = new Marquee({
|
|
24
|
+
container: ref.current,
|
|
25
|
+
speed,
|
|
26
|
+
isEnabled,
|
|
27
|
+
pauseOnHover,
|
|
28
|
+
prependWhitespace,
|
|
29
|
+
isFpsNormalized,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
setMarquee(instance);
|
|
33
|
+
|
|
34
|
+
return () => instance.destroy();
|
|
35
|
+
}, [isEnabled, isFpsNormalized, pauseOnHover, prependWhitespace, speed]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<button type="button" onClick={() => setWidth((val) => val + 20)}>
|
|
40
|
+
Rezize
|
|
41
|
+
</button>
|
|
42
|
+
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
onClick={() => marquee?.changeProps({ isEnabled: true })}
|
|
46
|
+
>
|
|
47
|
+
Play
|
|
48
|
+
</button>
|
|
49
|
+
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={() => marquee?.changeProps({ isEnabled: false })}
|
|
53
|
+
>
|
|
54
|
+
Pause
|
|
55
|
+
</button>
|
|
56
|
+
|
|
57
|
+
<button type="button" onClick={() => marquee?.render()}>
|
|
58
|
+
Manual render
|
|
59
|
+
</button>
|
|
60
|
+
|
|
61
|
+
<br />
|
|
62
|
+
<br />
|
|
63
|
+
|
|
64
|
+
<div style={{ background: '#ccc', width }}>
|
|
65
|
+
<span ref={ref}>Marquee</span>
|
|
66
|
+
</div>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NComponent } from '@/base/Component/types';
|
|
2
|
+
import { TOnResizeTarget } from '@/utils/listeners/onResize';
|
|
3
|
+
|
|
4
|
+
export namespace NMarquee {
|
|
5
|
+
export interface IStaticProps extends NComponent.IStaticProps {
|
|
6
|
+
/**
|
|
7
|
+
* Marquee container. You may use a CSS selector or the element itself.
|
|
8
|
+
* @default '#v-marquee'
|
|
9
|
+
*/
|
|
10
|
+
container?: string | HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Viewport target
|
|
13
|
+
* @default 'width'
|
|
14
|
+
*/
|
|
15
|
+
viewportTarget?: TOnResizeTarget;
|
|
16
|
+
/**
|
|
17
|
+
* Timeout of resize event
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
resizeDebounce?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IChangeableProps extends NComponent.IChangeableProps {
|
|
24
|
+
/**
|
|
25
|
+
* Marquee speed
|
|
26
|
+
* @default 1
|
|
27
|
+
*/
|
|
28
|
+
speed?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Enable animation
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
isEnabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Pause on hover
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
pauseOnHover?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Prepend a whitespace
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
prependWhitespace?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* On different screens with different FPS, animation may be slower or faster.
|
|
46
|
+
* This property is to normalize animation speed across different screens.
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
isFpsNormalized?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ICallbacksTypes extends NComponent.ICallbacksTypes {
|
|
53
|
+
render: undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -262,6 +262,9 @@ export default class Bar {
|
|
|
262
262
|
|
|
263
263
|
const { minSize, shouldAutoSize } = this.props;
|
|
264
264
|
|
|
265
|
+
// define if empty before other calculations
|
|
266
|
+
outer.classList.toggle(this.className('_is-empty'), scrollLine === 0);
|
|
267
|
+
|
|
265
268
|
// get outer sizes
|
|
266
269
|
this._outerHeight = outer.clientHeight;
|
|
267
270
|
this._outerWidth = outer.clientWidth;
|
|
@@ -287,9 +290,6 @@ export default class Bar {
|
|
|
287
290
|
this._thumbHeight = thumb.clientHeight;
|
|
288
291
|
this._thumbWidth = thumb.clientWidth;
|
|
289
292
|
|
|
290
|
-
// define if empty
|
|
291
|
-
outer.classList.toggle(this.className('_is-empty'), scrollLine === 0);
|
|
292
|
-
|
|
293
293
|
// render elements
|
|
294
294
|
this._renderThumb();
|
|
295
295
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './Ctx2DPrerender';
|
|
|
5
5
|
export * from './CustomCursor';
|
|
6
6
|
export * from './DraggerDirection';
|
|
7
7
|
export * from './DraggerMove';
|
|
8
|
+
export * from './Marquee';
|
|
8
9
|
export * from './Preloader';
|
|
9
10
|
export * from './ProgressPreloader';
|
|
10
11
|
export * from './ScrollBar';
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '3.
|
|
1
|
+
const version = '3.3.0';
|
|
2
2
|
export default version;
|