-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Create a way to disable mobile #596
Comments
Please! The website does not scroll on mobile and tablets. Please help me how can I disable the script for these devices, I'm very bad at understanding the script. Now I have this:
|
If you want to get rid of it on mobile altogether, I found this: if(!(/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone/i).test(navigator.userAgent || navigator.vendor || window.opera)){ |
Here's an example of what I did to disable skrollr on anything less than 600px wide:
You could probably incorporate @stefsullrew's suggestion instead of detecting window width. |
Oh, thanks!!! |
Damn! And yet I can't! Guys, please tell me how can I make it easier to create a javascript file and place the content or register in the body of the page?
I want to do as posted @rediris , please! |
If you put it directly in the HTML, did you wrap it in a script tag?
|
Yes, I wrapped the code!
I do not think that it is difficult for you, help me please! I'll pay! |
You can't have two returns in a single function. skrollr.init({
forceHeight: false,
smoothScrolling: true,
mobileCheck: function() {
return !(/Android|iPhone|iPad|iPod|BlackBerry/i).test(navigator.userAgent || navigator.vendor || window.opera);
}
}); |
Here's a slightly different approach, which is to disable skrollr for any device under 600px. The desire was to disable skrollr on phones, but enable it on some tablets. Also, since this checks to see if the "skrollr-body" ID exists on the body tag, this effectively prevents a scrolling bug that was happening in iOS 8 (where scrolling at the outer boundaries of the page [top and bottom] would trigger a scroll to the top of the page). This is not production-ready code, meaning, ditch the console.logs, etc and minify as necessary.
|
@rediris I'm still seeing the iOS 8 scrolling bug (jumping back to the top of the page) even with setting and detecting an ID/class on body. Did that completely solve the issue for you? My setup varies slightly in that I'm putting Actually it does make a difference having #skrollr-body not on the body tag. My reason for not putting it on the body is because I have elements that are position:fixed and was following @Prinzhorn recommendations here. |
@BradMcGonigle, since you're not setting You could try something like this (caveat: this is untested, and likely won't work in IE8):
|
Hello, I'm using Skrollr on body tag to have a nice parallax effect between the content and the fullscreen image background. "skrollr-body" id was added on body tag. Unfortunatly, I have trouble on mobile. I would like to delete the effect for iOS ...
Skrollr effect is gone but I miss all the content on the homepage when viewing on Ipad, Iphone5 is OK. How can I really get rid of skrollr on mobile ? |
This is what I have developed that works very well in all cases ... there's even an option to input an additional css file that handles ONLY mobile devices and is removed when not a mobile device ... since some laptops and notebooks are quite small, yet work well with skrollr, there is no reason to disable on these ... I've set my dimension for this particular project at 1024px ... but use as you need ... there are several console.log() notes in here to help with debugging ...
In the code references a development controller which assist in scroll position and viewport width/height ... if you need that code to help you out, let me know ... |
If you're using Modernizr, here is fairly simple way to prevent skrollr from initializing on any device with a touch screen:
I've found this works well in the real world, I've used this method on 5+ projects. Some might argue that this is preventing skrollr on tablets, but I'm usually ok with that. |
This is what I had to do; save a reference to Skrollr on the window (dirty, oh so dirty!): JavaScript
You could wrap this whole block in a function and call it on resize of the window, as well as on DOM ready. That way you can flip between it working and not working. I've confirmed that this works above and beyond just using destroy() and therefore by extension, eliminates the jumping iOS bug. |
Skrollr is really awesome. It would be even more awesome if there were a simple way to disable mobile. I'd rather not have the movement on mobile since I'm giving it a very different look. (If I've missed the way to do this, please point me in the right direction?)
Cheers
The text was updated successfully, but these errors were encountered: