0

I am creating new web and need help with JavaScript. What I want is disable scrollify JS on mobile. Tried almost everything, not success.

Here is my code:

<script>
            $(function() {
                    $.scrollify({
                        section : ".pagescroll",
                        standardScrollElements: ".modal",
                    });
              $.scrollify.disable() // this function is for disable mobile
                });
</script>

Thank you

YakaMan
  • 1
  • 1
  • 3

4 Answers4

2
jQuery.scrollify({
    touchScroll: false
});

touchScroll: A boolean to define whether Scrollify handles touch scroll events. True by default.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Lastron
  • 21
  • 2
1

Why don't you check if it's mobile using userAgent and regex like this

You can execute your script only if it's not mobile

if(!(/Android|webOS|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(navigator.userAgent) )) { //if not these devices(userAgents)

  $(function() {
      $.scrollify({
          section : ".pagescroll",
          standardScrollElements: ".modal",
      });
  });

}

You can try the below snippet in mobile SO site also. It's working

if(!(/Android|webOS|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(navigator.userAgent) )) { //if not these userAgents
  console.log("Not Mobile..!");
}else{
  console.log("This is Mobile");
}
Jyothi Babu Araja
  • 10,076
  • 3
  • 31
  • 38
  • Looking at the userAgent is not a very good idea; it is not reliable and must be maintained. – Jeroen Heier Nov 27 '16 at 13:02
  • need a help because I am newbie in JavaScript functions. Thank you – YakaMan Nov 27 '16 at 13:27
  • tried and not working. Any other solution? thank you – YakaMan Nov 27 '16 at 16:09
  • `if(!(/Android|webOS|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(navigator.userAgent) )) { //if not these userAgents $(function() { $.scrollify({ section : ".pagescroll", standardScrollElements: ".modal", }); }); }else{ $.scrollify.disable(); }` – YakaMan Nov 28 '16 at 23:15
  • The problem is that, when I use the `$.scrollify.disable()` I can not roll page up and down. It is disabling whole web. I think this function disable the whole scroll. But I want only turn off scrollify.js. Maybe it is need to be enabled back somehow. – YakaMan Nov 28 '16 at 23:24
  • Try removing `else` part of your code. i.e don't disable `scrollify` which means we're not initialising in Mobile – Jyothi Babu Araja Nov 29 '16 at 05:31
0

check this code...

<script>
$(document).ready(function () {
    var width = $(window).width();
    var height = $(window).height();

    if (width > 980 && height > 500) {
        $(function () {
            $(".panel").css({
                "height": $(window).height()
            });
            $.scrollify({
                section: ".panel"
            });


            $(".scroll").click(function (e) {
                e.preventDefault();
                $.scrollify("move", $(this).attr("href"));
            });
        });

    } else {
        $(".scroll").click(function (e) {
            e.preventDefault();
        });
        $.scrollify.destroy();
    }
    $(window).resize(function () {
        width = $(window).width();
        height = $(window).height();
        $(function () {
            if (width > 980 && height > 500) {
                $(".panel").css({
                    "height": $(window).height()
                });
                $.scrollify({
                    section: ".panel"
                });


                $(".scroll").click(function (e) {
                    e.preventDefault();
                    $.scrollify("move", $(this).attr("href"));
                });
            } else {
                $.scrollify.destroy();
                $(".scroll").click(function (e) {
                    e.preventDefault();
                });

            }
        });
    });
});

  • Welcome to SO. When posting an answer, please include comments explaining what was the issue and how your code resolves it. – Fejs Sep 10 '17 at 06:54
0
$.scrollify({
 section : ".fullSec",
 scrollSpeed:2000,
 easing: "easeOutExpo",
 offset : 0,
 scrollbars: true,
 setHeights: true,
 updateHash: false,
 afterResize: function() {
 if( $(window).width() < 767) {
   $.scrollify.disable()
 }else{
   $.scrollify.enable()
 }
 },
});
Ankur Pandey
  • 1
  • 1
  • 1