Skip to content

Commit

Permalink
Fix scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
armandocat committed Oct 10, 2017
1 parent f848939 commit c0692d1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


var iframeStyle = `
body, html { height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.top-bar.header { display:none; }
div.search-content { margin-top: -25px; }
form.gsc-search-box { display:none; }
Expand Down Expand Up @@ -95,6 +96,25 @@
openSearch(container, input.val());
});

// prevent page scroll if mouse is no top of the list
if(!$('html').hasClass('smi-mobile')){
var s = { insideIframe: false };

container.find('iframe').mouseenter(function() {
s.insideIframe = true;
s.scrollX = window.scrollX;
s.scrollY = window.scrollY;
}).mouseleave(function() {
s.insideIframe = false;
});

$(document).scroll(function() {
if (s.insideIframe){
window.scrollTo(s.scrollX, s.scrollY);
}
});
}

return container;
};

Expand Down

0 comments on commit c0692d1

Please sign in to comment.