-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "idea-react", | ||
"version": "0.25.0", | ||
"version": "0.26.0", | ||
"license": "LGPL-3.0", | ||
"author": "[email protected]", | ||
"description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import classNames from 'classnames'; | ||
import React, { FC, ReactNode } from 'react'; | ||
|
||
export type EdgePosition = 'top' | 'bottom' | 'left' | 'right'; | ||
|
||
type TouchHandler = (edge: EdgePosition) => any; | ||
|
||
export interface ScrollBoundaryProps | ||
extends Partial<Record<EdgePosition, ReactNode>> { | ||
className?: string; | ||
onTouch: TouchHandler; | ||
} | ||
|
||
function touch(edge: EdgePosition, onTouch: TouchHandler) { | ||
return (node: HTMLElement | null) => | ||
node && | ||
new IntersectionObserver( | ||
([{ isIntersecting }]) => isIntersecting && onTouch(edge) | ||
).observe(node); | ||
} | ||
|
||
export const ScrollBoundary: FC<ScrollBoundaryProps> = ({ | ||
className, | ||
onTouch, | ||
top, | ||
left, | ||
right, | ||
bottom, | ||
children | ||
}) => ( | ||
<div className={classNames('position-relative', className)}> | ||
<div | ||
className="position-absolute top-0 left-0 w-100" | ||
ref={touch('top', onTouch)} | ||
> | ||
{top} | ||
</div> | ||
<div | ||
className="position-absolute top-0 left-0 h-100" | ||
ref={touch('left', onTouch)} | ||
> | ||
{left} | ||
</div> | ||
|
||
{children} | ||
|
||
<div | ||
className="position-absolute top-0 right-0 h-100" | ||
ref={touch('right', onTouch)} | ||
> | ||
{right} | ||
</div> | ||
<div | ||
className="position-absolute top-100 left-0 w-100" | ||
ref={touch('bottom', onTouch)} | ||
> | ||
{bottom} | ||
</div> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4028348
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for idea-react ready!
✅ Preview
https://idea-react-pwcibqds9-stevending1st.vercel.app
Built with commit 4028348.
This pull request is being automatically deployed with vercel-action