/    Sign up×
Community /Pin to ProfileBookmark

scroll right by scrolling down, left by scrolling up

I’m attempting to make a photo gallery page that scrolls horizontally only. I would like to make it scroll to the right when I scroll down, to left when scrolling up etc., without disabling the standard left and right scrolling. I’ve included a fiddle for context. Thanks in advance – https://jsfiddle.net/JosueOrNoSway/6ds7mqkf/2/

html-

<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<link rel=”stylesheet” type=”text/css” href=”css/main.css”>
<link rel=”stylesheet” type=”text/css” href=”css/lightbox.min.css”>
<title>Photo Gallery</title>
</head>

<body>
<h1>Photo Gallery</h1>

<div class=”gallery”>

<ul class=”top-row”>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>

</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
<li>
<div class=”filler”></div>
</li>
</ul>

<ul class=”bottom-row”>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
<li>
<div class=”filler2″></div>
</li>
</ul>
</div>

<script type=”text/javascript” src=”js/lightbox-plus-jquery.min.js”>
</script>
<script src=”js/main.js”></script>

</body>
</html>

css –

body {
font-family: sans-serif;
background: #000;
margin: 0;
padding: 0;
height: 100vh;
overflow-y: hidden;
}

h1 {
color: #fff;
margin: 50px 0 0 100px;
font-size: 5rem;
}

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@thebronxsystemSep 20.2018 — im not a wizard at javascript but isnt there a mouse event that you can use? then just make a function that scrolls on x or y axsis

onwheel function(){ return false; } should disable default behavior

i will try tomorrow ^^
×

Success!

Help @JosueOrNoSway spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...