Skip to content

Commit fb96334

Browse files
authored
Merge pull request #94 from CodeWithGroup/feature/fix-IPad-Sidebar
Fixes an issue where the sidebar would reopen on scroll on Apple Devices
2 parents a2e831d + 1e92522 commit fb96334

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

js/check-width.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ $(function () {
44
var $window = $(window);
55
var $pane = $('#main-container');
66

7+
// Store the window width
8+
var windowWidth = $window.width();
9+
710
function checkWidth() {
8-
var windowsize = $window.width();
9-
if (windowsize <= 768) {
10-
if ($pane.hasClass('toggled')) {
11-
$pane.toggleClass('toggled');
11+
if ($(window).width() != windowWidth) {
12+
var windowsize = $window.width();
13+
if (windowsize <= 768) {
14+
if ($pane.hasClass('toggled')) {
15+
$pane.toggleClass('toggled');
16+
}
17+
}
18+
else if (!$pane.hasClass('toggled')) {
19+
$pane.addClass('toggled');
1220
}
13-
}
14-
else if (!$pane.hasClass('toggled')) {
15-
$pane.addClass('toggled');
1621
}
1722
}
1823

0 commit comments

Comments
 (0)