react-scroll-to-top
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -15,3 +15,3 @@ "use strict"; | ||
var ScrollToTop = function (_a) { | ||
var _b = _a.top, top = _b === void 0 ? 20 : _b, _c = _a.color, color = _c === void 0 ? "black" : _c, _d = _a.backgroundColor, backgroundColor = _d === void 0 ? "white" : _d; | ||
var _b = _a.top, top = _b === void 0 ? 20 : _b, _c = _a.color, color = _c === void 0 ? "black" : _c, _d = _a.bgColor, bgColor = _d === void 0 ? "white" : _d; | ||
var _e = react_1.useState(false), visible = _e[0], setVisible = _e[1]; | ||
@@ -30,20 +30,17 @@ react_1.useEffect(function () { | ||
opacity: "0.4", | ||
color: color, | ||
border: "none", | ||
backgroundColor: backgroundColor, | ||
borderRadius: 15, | ||
border: "1px solid black", | ||
backgroundColor: bgColor, | ||
borderRadius: 7, | ||
width: 40, | ||
transition: "bottom 0.3s ease-in-out", | ||
transition: "opacity .25s ease-in-out", | ||
height: 40, | ||
boxShadow: "0 9px 25px 0 rgba(132,128,177,0.28)", | ||
}; | ||
console.log("rerender"); | ||
var onScroll = function () { | ||
setVisible(document.documentElement.scrollTop > top); | ||
console.log("scrolling", document.documentElement.scrollTop > top); | ||
}; | ||
return (react_1.default.createElement(react_1.default.Fragment, null, visible && (react_1.default.createElement("button", { style: style, onClick: scrollToTop }, | ||
react_1.default.createElement("svg", { fill: "black", viewBox: "0 0 256 256" }, | ||
react_1.default.createElement("svg", { fill: color, viewBox: "0 0 256 256" }, | ||
react_1.default.createElement("path", { d: "M222.138,91.475l-89.6-89.6c-2.5-2.5-6.551-2.5-9.051,0l-89.6,89.6c-2.5,2.5-2.5,6.551,0,9.051s6.744,2.5,9.244,0L122,21.85 V249.6c0,3.535,2.466,6.4,6,6.4s6-2.865,6-6.4V21.85l78.881,78.676c1.25,1.25,2.992,1.875,4.629,1.875s3.326-0.625,4.576-1.875 C224.586,98.025,224.638,93.975,222.138,91.475z" })))))); | ||
}; | ||
exports.default = ScrollToTop; |
{ | ||
"name": "react-scroll-to-top", | ||
"author": "Herman Nygaard", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "lib/ScrollToTop.js", | ||
@@ -23,2 +23,7 @@ "types": "lib/ScrollToTop.d.ts", | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/HermanNygaard/react-scroll-to-top" | ||
}, | ||
"devDependencies": { | ||
@@ -25,0 +30,0 @@ "@types/react": "^16.9.34", |
# react-scroll-to-top | ||
A simple button component that scrolls to the top of the page when pressed\ | ||
The button is only visible when a certain height has been reached on the page\ | ||
Demo coming | ||
@@ -29,6 +30,7 @@ | ||
toTop number default 20 | ||
color string color of the icon default black | ||
backgroundColor string color of the buttons background default white | ||
position: left, right | ||
| Prop | Type | Description | Default | | ||
| ------- | ------ | ---------------------------------------- | ------- | | ||
| top | number | The height where the button gets visible | 20 | | ||
| color | string | The arrow color | white | | ||
| bgColor | string | Button background color | black | | ||
@@ -35,0 +37,0 @@ ## Types |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
4248
39
0
55