Horizontal Scroll with device motion
How do I make an horizontal scroll with device motion?
What is a horizontal scroll with device motion? How do you make a horizontal scroll with device motion? This script and codes were developed by Nick Colley on 12 November 2022, Saturday.
Horizontal Scroll with device motion - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Horizontal Scroll with device motion</title> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <meta name="viewport" content="width=device-width">
<div id="info"></div>
<div class="responsive-scroll"> <img src="http://images.nationalgeographic.com/wpf/media-live/photos/000/465/cache/horses-southern-iceland_46570_990x742.jpg" alt="horsies" />
</div>
<pre class="responsive-scroll"> console.log('codecodecode'); function superlongfunctionnameomg() { return 'wow line character limit pls'; }
</pre> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Horizontal Scroll with device motion - Script Codes CSS Codes
html,
body { height: 100%; width: 100%;
}
.responsive-scroll { height: 500px; overflow-x: auto; overflow-y: hidden;
}
.responsive-scroll > img { height: 100%;
}
Horizontal Scroll with device motion - Script Codes JS Codes
console.clear();
var elems = document.querySelectorAll('.responsive-scroll');
if (window.DeviceOrientationEvent) { window.addEventListener('deviceorientation', function (e) { var tilt = e.gamma; if(lowpassfilter(tilt, 0.5)) { deviceOrientationHandler(e.gamma); } }, false);
}
function deviceOrientationHandler(gamma) { for (var i = 0; i < elems.length; i++) { var elm_width = elems[i].clientWidth / 2; elems[i].scrollLeft = (gamma - (elm_width / 20)) * -20; }
}
var lpf = 0;
function lowpassfilter(num, scale) { var top = lpf + scale; var bottom = lpf - scale; lpf = num; if( num < top && num > bottom ) { return false; } return true;
}
Developer | Nick Colley |
Username | nickcolley |
Uploaded | November 12, 2022 |
Rating | 3 |
Size | 2,446 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Henry Homesweet Boxmodel | 3,747 Kb |
Wip elementary os navbar | 2,993 Kb |
Banner hover test | 2,825 Kb |
A Pen by Nick Colley | 18,585 Kb |
Curl Dropshadow | 1,623 Kb |
Diagonal Nav bar | 2,392 Kb |
Brightness regulation UI design | 2,713 Kb |
Erno | 5,311 Kb |
Flickering TV | 167,407 Kb |
One element icon | 1,976 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Parallax with only CSS | Thulioph | 2,297 Kb |
Birthday Party Starter | Aussieyang | 1,629 Kb |
Image Hover | Johnheiner | 3,409 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 Kb |
Greyscale image with filter in CSS3 | NickyCDK | 1,562 Kb |
Material Design-Layout-Principles Practice | Fraina | 2,331 Kb |
Portfolio Page | KaylaMT | 1,983 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
CSS Org Chart | Appirio-ux | 3,882 Kb |
Ripples in water | Nobitagit | 2,704 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!