somewebmedia / hc-sticky

JavaScript library that makes any element on your page visible while you scroll.
https://somewebmedia.github.io/hc-sticky/
MIT License
463 stars 115 forks source link

How do disable for mobile and tablet? #43

Closed ghost closed 6 years ago

ghost commented 6 years ago

I am having trouble understanding how I can disable this plugin for mobile and tablet users. at the moment I've tried using the destroy and the onresize options but I am obviously doing something wrong. Can anyone direct me on how these are supposed to be combined so I can create the state change I need?

$(document).ready(function(){
  $("[data-sticky_column_1]").hcSticky({
    stickTo: "[data-sticky_parent_1]",
    onResize: function () {
      console.log(arguments);
    }
  });

Thanks!

carasmo commented 6 years ago

I downloaded the master and there are examples for disabling for media queries in the demo / build directory

You can't disable for actual device tablets and/or phones with this script, or any other similar script. If you need to do that, I would use server side detection, for example Mobile Detect php class.

ghost commented 6 years ago

@carasmo Thank you - at least that's a start!

Say if I want to disable the script from 768px (typical tablet) downwards how would I manipulate this to cater for that kind of request?

      queries: {
        980: {
          disable: true
        }
      }
carasmo commented 6 years ago

Change the breakpoint to 767. You can see what options in the read me: :

ghost commented 6 years ago

Of course! 🤪

thank you

carasmo commented 6 years ago

Cool. Please close, this is not a bug report or a feature request. Thanks!