react-scrollable-feed
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -1,3 +0,9 @@ | ||
# Change Log | ||
# Change Log | ||
<a name="1.3.0"></a> | ||
## [1.2.0](https://github.com/dizco/react-scrollable-feed/compare/v1.2.0...v1.3.0) (2020-09-30) | ||
* Added `scrollToBottom` public method | ||
* Fix issue with scrolling when wrapper has fixed height ([#34](https://github.com/dizco/react-scrollable-feed/issues/34)) | ||
* Updated dependencies | ||
<a name="1.2.0"></a> | ||
@@ -4,0 +10,0 @@ ## [1.2.0](https://github.com/dizco/react-scrollable-feed/compare/v1.1.2...v1.2.0) (2020-09-30) |
@@ -31,2 +31,3 @@ import * as React from 'react'; | ||
* Returns whether a child element is visible within a parent element | ||
* | ||
* @param parent | ||
@@ -41,4 +42,8 @@ * @param child | ||
protected handleScroll(): void; | ||
/** | ||
* Scroll to the bottom | ||
*/ | ||
scrollToBottom(): void; | ||
render(): React.ReactNode; | ||
} | ||
export default ScrollableFeed; |
@@ -114,2 +114,3 @@ import { createElement, createRef, Component } from 'react'; | ||
* Returns whether a child element is visible within a parent element | ||
* | ||
* @param parent | ||
@@ -125,3 +126,4 @@ * @param child | ||
var childTopIsViewable = (childRect.top >= parentRect.top); | ||
var childBottomIsViewable = (Math.abs(parentRect.top + parent.clientHeight - childRect.top) <= epsilon); //Use epsilon because getBoundingClientRect might return floats https://stackoverflow.com/a/40879359/6316091 | ||
var childOffsetToParentBottom = parentRect.top + parent.clientHeight - childRect.top; | ||
var childBottomIsViewable = childOffsetToParentBottom + epsilon >= 0; | ||
return childTopIsViewable && childBottomIsViewable; | ||
@@ -139,2 +141,10 @@ }; | ||
}; | ||
/** | ||
* Scroll to the bottom | ||
*/ | ||
ScrollableFeed.prototype.scrollToBottom = function () { | ||
if (this.bottomRef.current && this.wrapperRef.current) { | ||
this.scrollParentToChild(this.wrapperRef.current, this.bottomRef.current); | ||
} | ||
}; | ||
ScrollableFeed.prototype.render = function () { | ||
@@ -141,0 +151,0 @@ var _a = this.props, children = _a.children, className = _a.className; |
@@ -118,2 +118,3 @@ 'use strict'; | ||
* Returns whether a child element is visible within a parent element | ||
* | ||
* @param parent | ||
@@ -129,3 +130,4 @@ * @param child | ||
var childTopIsViewable = (childRect.top >= parentRect.top); | ||
var childBottomIsViewable = (Math.abs(parentRect.top + parent.clientHeight - childRect.top) <= epsilon); //Use epsilon because getBoundingClientRect might return floats https://stackoverflow.com/a/40879359/6316091 | ||
var childOffsetToParentBottom = parentRect.top + parent.clientHeight - childRect.top; | ||
var childBottomIsViewable = childOffsetToParentBottom + epsilon >= 0; | ||
return childTopIsViewable && childBottomIsViewable; | ||
@@ -143,2 +145,10 @@ }; | ||
}; | ||
/** | ||
* Scroll to the bottom | ||
*/ | ||
ScrollableFeed.prototype.scrollToBottom = function () { | ||
if (this.bottomRef.current && this.wrapperRef.current) { | ||
this.scrollParentToChild(this.wrapperRef.current, this.bottomRef.current); | ||
} | ||
}; | ||
ScrollableFeed.prototype.render = function () { | ||
@@ -145,0 +155,0 @@ var _a = this.props, children = _a.children, className = _a.className; |
{ | ||
"name": "react-scrollable-feed", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "", | ||
@@ -37,11 +37,11 @@ "author": "dizco", | ||
"@types/jest": "^24.9.1", | ||
"@types/react": "^16.9.49", | ||
"@types/react-dom": "^16.9.8", | ||
"@types/react": "^16.14.3", | ||
"@types/react-dom": "^16.9.10", | ||
"babel-core": "^6.26.3", | ||
"babel-runtime": "^6.26.0", | ||
"cross-env": "^5.2.1", | ||
"cypress": "^3.8.3", | ||
"cypress": "^6.4.0", | ||
"gh-pages": "^2.2.0", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react": "^16.14.0", | ||
"react-dom": "^16.14.0", | ||
"react-scripts-ts": "^4.0.8", | ||
@@ -52,7 +52,7 @@ "rollup": "^1.32.1", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-peer-deps-external": "^2.2.3", | ||
"rollup-plugin-peer-deps-external": "^2.2.4", | ||
"rollup-plugin-postcss-modules": "2.0.1", | ||
"rollup-plugin-typescript2": "^0.21.2", | ||
"rollup-plugin-url": "^2.2.4", | ||
"typescript": "^3.9.7" | ||
"typescript": "^3.9.9" | ||
}, | ||
@@ -59,0 +59,0 @@ "files": [ |
@@ -161,2 +161,10 @@ <h1 align="center" style="border-bottom: none;">react-scrollable-feed</h1> | ||
## Public Methods | ||
### scrollToBottom | ||
- Signature: `() => void` | ||
Scroll to the bottom | ||
## For more details | ||
@@ -163,0 +171,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
68896
370
180