Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update button text and initial paint in example app #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cypress/integration/useIntersectionObserver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ before(() => {

describe('useIsInViewport', () => {
it('should report correctly when an element is visible in parent document', () => {
cy.get('[data-testid="toggle-simple-parent-doc-test"]').should(
'contain',
'Show simple parent doc test'
)
cy.get('[data-testid="toggle-simple-parent-doc-test"]').click()
cy.get('[data-testid="toggle-simple-parent-doc-test"]').should(
'contain',
'Hide simple parent doc test'
Expand Down
2 changes: 1 addition & 1 deletion examples/cra/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from './viewportAnotherElement'

function App() {
const [testToShow, setTestToShow] = React.useState(1)
const [testToShow, setTestToShow] = React.useState(0)
const forwardedTargetRef = node => {
window.forwardedTargetRef = window.forwardedTargetRef || []
window.forwardedTargetRef.push(node)
Expand Down
4 changes: 2 additions & 2 deletions examples/cra/src/viewportAnotherElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function SimpleElement() {
onClick={() => toggleHide(h => !h)}
data-testid="toggle-box-position"
>
{hidden ? 'Show box' : 'Hide box'}
{hidden ? 'Show box (or scroll to show it)' : 'Hide box'}
</button>
<div ref={viewportRef} data-testid="viewport" className={container}>
<div
Expand Down Expand Up @@ -65,7 +65,7 @@ export const RefForwardingElement = React.forwardRef(function RefForwardingEleme
onClick={() => toggleHide(h => !h)}
data-testid="toggle-boxes-positions"
>
{hidden ? 'Show boxes' : 'Hide boxes'}
{hidden ? "Show boxes (or scroll to show 'em)" : 'Hide boxes'}
</button>
<div ref={finalParentRef} data-testid="viewport" className={cx('viewport', container)}>
<div
Expand Down
4 changes: 2 additions & 2 deletions examples/cra/src/viewportParentDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function SimpleElement() {
onClick={() => toggleHide(h => !h)}
data-testid="toggle-box-position"
>
{hidden ? 'Show box' : 'Hide box'}
{hidden ? 'Show box (or scroll to show it)' : 'Hide box'}
</button>
<div
className={cx(box, {
Expand Down Expand Up @@ -57,7 +57,7 @@ export const RefForwardingElement = React.forwardRef(function RefForwardingEleme
onClick={() => toggleHide(h => !h)}
data-testid="toggle-box-position"
>
{hidden ? 'Show box' : 'Hide box'}
{hidden ? 'Show box (or scroll to show it)' : 'Hide box'}
</button>
<div
className={cx('target-div', box, {
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"tslint --fix",
"git add"
],
"cypress/integration/**/*.js": [
"prettier --write",
"git add"
],
"*.{json,md,html,css}": [
"prettier --write",
"git add"
Expand Down