Skip to content

Commit d30afd2

Browse files
committed
fix(css): ensure that iOS scroll lock only applies if print view is inactive
refs ibi-group/trimet-mod-otp#117
1 parent 4e2a7a7 commit d30afd2

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

lib/components/app/print-layout.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ class PrintLayout extends Component {
3939
}
4040
}
4141

42+
/**
43+
* Add print-view class to html tag to ensure that iOS scroll fix only applies
44+
* to non-print views.
45+
*/
46+
componentWillMount () {
47+
const root = document.getElementsByTagName('html')[0]
48+
root.setAttribute('class', 'print-view')
49+
}
50+
51+
/**
52+
* Remove class attribute from html tag on clean up.
53+
*/
54+
componentWillUnmount () {
55+
const root = document.getElementsByTagName('html')[0]
56+
root.removeAttribute('class')
57+
}
58+
4259
render () {
4360
const { itinerary, companies } = this.props
4461
return (

lib/index.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818

1919
/* PREVENT BOUNCE SCROLL ON iOS */
2020
@supports (-webkit-overflow-scrolling: touch) {
21-
/* Fix this body and html to prevent bounce */
22-
html,
23-
body {
21+
/* Fix the body and html to prevent bounce (only if print-view is not active) */
22+
html:not(.print-view),
23+
html:not(.print-view) body {
2424
position: fixed;
2525
overflow: hidden;
2626
font-family: Arial, Helvetica, sans-serif;
2727
}
28-
/* Modify the root/main div to permit normal scrolling behavior */
29-
#root, #main {
28+
/* Modify the root/main div to permit normal scrolling behavior (only if
29+
print-view is not active) */
30+
html:not(.print-view) #root,
31+
html:not(.print-view) #main {
3032
width: 100vw;
3133
height: 100vh;
3234
-webkit-overflow-scrolling: touch;

0 commit comments

Comments
 (0)