Horizontal Scroll with device motion

Developer
Size
2,446 Kb
Views
26,312

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 Previews

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;
}
Horizontal Scroll with device motion - Script Codes
Horizontal Scroll with device motion - Script Codes
Home Page Home
Developer Nick Colley
Username nickcolley
Uploaded November 12, 2022
Rating 3
Size 2,446 Kb
Views 26,312
Do you need developer help for Horizontal Scroll with device motion?

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!

Nick Colley (nickcolley) Script Codes
Create amazing marketing copy with AI!

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!