Skip to content

Fixed nested lock scroll problem #73

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

Merged
merged 1 commit into from
May 11, 2019
Merged
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
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class Popup extends React.PureComponent {
/* eslint-disable-next-line no-undef */
window.removeEventListener('resize', this.repositionOnResize);
}
this.resetScroll();
}

repositionOnResize = () => {
Expand Down
59 changes: 59 additions & 0 deletions stories/src/NestedLockScroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import {Centred} from 'story-router';

import Popup from '../../src';

const NestedLockScrollProps = {
closeOnDocumentClick: true,
closeOnEscape: true,
on: ['click'],
position: 'bottom center',
arrow: true,
offsetX: 0,
offsetY: 0,
};

const NestedLockScroll = props => {
return (
<div style={{height: '200vh', position: 'relative', textAlign: 'center'}}>
<div>Try to scroll down before pressing the button.</div>
<Popup {...props} trigger={<button>Button Trigger</button>}>
{close => (
<div>
sum dolor sit amet consectetur adipisicing elit. Nemo voluptas ex,
blanditiis reiciendis dolor numquam pariatur facilis, labore, libero
nihil asperiores ae facilis quis commodi dolores, at enim. Deserunt
qui, officiis culpa optio numquam ullam pariatur voluptas tempora
doloremque!
<Popup
on="click"
position="bottom left"
closeOnDocumentClick
modal
lockScroll
trigger={<button>Button nested</button>}
onClose={close}>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo
voluptas ex, blanditiis reiciendis dolor numquam pariatur
facilis, labore, libero nihil asperiores ae facilis quis commodi
dolores, at enim. Deserunt qui, officiis culpa optio numquam
ullam pariatur voluptas tempora doloremque!
</div>
</Popup>
</div>
)}
</Popup>
<div style={{position: 'absolute', bottom: 0}}>
Can you still scroll to me?
</div>
</div>
);
};

const NestedLockScrollStory = {
name: 'Nested lock scroll',
component: Centred(NestedLockScroll),
props: NestedLockScrollProps, // adding props
};
export default NestedLockScrollStory;
8 changes: 5 additions & 3 deletions stories/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Centred } from "story-router";
import Story from "./Story";
//import { Centred } from "../../src/utils/";
import {Centred} from 'story-router';
import Story from './Story';
// import { Centred } from "../../src/utils/";

import PopupElementStory from './PopupElement';
import PopupFuncStory from './PopupFunc';
Expand All @@ -14,6 +14,7 @@ import ControlledTooltip from './ControlledTooltip';
import BoundedTooltip from './BoundedTooltip';

import CellTablePopupStory from './CellTablePopup';
import NestedLockScrollStory from './NestedLockScroll';

const storyProps = {text: 'Parcel Storybook'};
const buttonProps = {
Expand Down Expand Up @@ -78,4 +79,5 @@ export default [
PopupInputFocusStory,
PopupElementStory,
CellTablePopupStory,
NestedLockScrollStory,
];