react-scroll-to-top
Advanced tools
Comparing version 2.0.3-beta.1 to 2.0.3-beta.2
@@ -93,10 +93,10 @@ 'use strict'; | ||
var _l = React.useState(false), visible = _l[0], setVisible = _l[1]; | ||
var onScroll = function () { | ||
setVisible(document.documentElement.scrollTop > top); | ||
}; | ||
React.useEffect(function () { | ||
var onScroll = function () { | ||
setVisible(document.documentElement.scrollTop >= top); | ||
}; | ||
onScroll(); | ||
document.addEventListener("scroll", onScroll); | ||
// Remove listener on unmount | ||
return function () { return document.removeEventListener("scroll", onScroll); }; | ||
}, []); | ||
}, [top]); | ||
return (React__default.createElement(React__default.Fragment, null, visible && (React__default.createElement("button", __assign({ className: className, onClick: function () { return scrollToTop(smooth); }, "aria-label": "Scroll to top" }, props), component || (React__default.createElement("svg", { width: width, height: height, fill: color, viewBox: viewBox }, | ||
@@ -103,0 +103,0 @@ React__default.createElement("path", { d: svgPath }))))))); |
{ | ||
"name": "react-scroll-to-top", | ||
"author": "Herman Nygaard", | ||
"version": "2.0.3-beta.1", | ||
"version": "2.0.3-beta.2", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
16501