fix(menu/scroll): Allows effect only on mobile

This commit is contained in:
sovanna 2020-01-22 16:10:41 +01:00
parent 0191350c48
commit 5f42340b04
1 changed files with 20 additions and 0 deletions

View File

@ -210,12 +210,32 @@
</script>
<script>
function deviceIsMobile() {
// https://coderwall.com/p/i817wa/one-line-function-to-detect-mobile-devices-with-javascript
return (
(typeof window.orientation !== 'undefined') ||
navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i) ||
(navigator.userAgent.indexOf('IEMobile') !== -1)
);
};
(function () {
var mywindow = $(window);
var mypos = mywindow.scrollTop();
var up = false;
var newscroll;
var navbarSupportedContent = $('#navbarSupportedContent');
if (!deviceIsMobile()) {
return;
}
mywindow.scroll(function () {
newscroll = mywindow.scrollTop();
if (newscroll < 30) {