@etsoo/materialui 1.2.3 → 1.2.4
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/ScrollTopFab.d.ts +1 -1
- package/lib/ScrollTopFab.js +5 -5
- package/package.json +1 -1
- package/src/ScrollTopFab.tsx +26 -24
package/lib/ScrollTopFab.d.ts
CHANGED
package/lib/ScrollTopFab.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Fab, useScrollTrigger, Zoom } from
|
|
3
|
-
import VerticalAlignTopIcon from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Fab, useScrollTrigger, Zoom } from "@mui/material";
|
|
3
|
+
import VerticalAlignTopIcon from "@mui/icons-material/VerticalAlignTop";
|
|
4
4
|
/**
|
|
5
5
|
* Scroll to top fab
|
|
6
6
|
* @returns Component
|
|
@@ -19,7 +19,7 @@ export function ScrollTopFab(props) {
|
|
|
19
19
|
const handleClick = () => {
|
|
20
20
|
target.scrollTo({ top: 0 });
|
|
21
21
|
};
|
|
22
|
-
return (React.createElement(Zoom, { in: trigger },
|
|
22
|
+
return trigger ? (React.createElement(Zoom, { in: trigger },
|
|
23
23
|
React.createElement(Fab, { color: color, size: size, title: title, onClick: handleClick },
|
|
24
|
-
React.createElement(VerticalAlignTopIcon, null))));
|
|
24
|
+
React.createElement(VerticalAlignTopIcon, null)))) : (React.createElement(React.Fragment, null));
|
|
25
25
|
}
|
package/package.json
CHANGED
package/src/ScrollTopFab.tsx
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Fab, useScrollTrigger, Zoom } from
|
|
3
|
-
import VerticalAlignTopIcon from
|
|
4
|
-
import { CustomFabProps } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Fab, useScrollTrigger, Zoom } from "@mui/material";
|
|
3
|
+
import VerticalAlignTopIcon from "@mui/icons-material/VerticalAlignTop";
|
|
4
|
+
import { CustomFabProps } from "./CustomFabProps";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Scroll to top fab
|
|
8
8
|
* @returns Component
|
|
9
9
|
*/
|
|
10
10
|
export function ScrollTopFab(props: CustomFabProps) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Destruct
|
|
12
|
+
const { color, size, target, title } = props;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
// Scroll trigger
|
|
15
|
+
const trigger = useScrollTrigger({
|
|
16
|
+
target,
|
|
17
|
+
disableHysteresis: true,
|
|
18
|
+
threshold: 120
|
|
19
|
+
});
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// Icon click handler
|
|
22
|
+
// behavior: 'smooth'
|
|
23
|
+
const handleClick = () => {
|
|
24
|
+
target.scrollTo({ top: 0 });
|
|
25
|
+
};
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
return trigger ? (
|
|
28
|
+
<Zoom in={trigger}>
|
|
29
|
+
<Fab color={color} size={size} title={title} onClick={handleClick}>
|
|
30
|
+
<VerticalAlignTopIcon />
|
|
31
|
+
</Fab>
|
|
32
|
+
</Zoom>
|
|
33
|
+
) : (
|
|
34
|
+
<React.Fragment />
|
|
35
|
+
);
|
|
34
36
|
}
|