Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional loading of script based on screen height/width. #33

Open
klummy opened this issue Apr 23, 2014 · 1 comment
Open

Conditional loading of script based on screen height/width. #33

klummy opened this issue Apr 23, 2014 · 1 comment

Comments

@klummy
Copy link

klummy commented Apr 23, 2014

Great work on scrollIt.

However, is it possible to conditionally load the script based on browser height/width? My design goes to hell at height = 550px & below and I would like to load the script for heights greater than that. Something like this:

<script type="text/javascript"> var currentHeight = window.outerHeight; $document.ready(function() { if (currentHeight > 550) { var body = document.getElementsByTagName("body"); //Find document var scroller = document.createElement("script");//Create <script> element scroller.src = "js/scrollIt.min.js"; //Set its src body.append(scroller); //Insert the script } }) </script>

However, as you may have guessed, my JS skills are pretty poor & I can't get this to work. You may also take a look at the site - ouroja.com - for a demonstration.

Thanks.

@markdieselcore
Copy link

$(function () {
    $(window).resize(function () {
        if ( $(window).width() > 550 ) {  // run the code

// ScrollIt
$(function(){
  $.scrollIt({
  easing: 'linear',      // the easing function for animation
  scrollTime: 600,       // how long (in ms) the animation takes
  activeClass: 'active', // class given to the active nav element
});
});

        }
    }).resize(); //call resize function 
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants