In the previous topic, with your help, we implemented a functional that allows you to collapse-expand a block when you click on the arrow. Now I am interested in the question: how to make a drop-down list for mobile devices not by taboo, but by swipe up and down? I have hooked up the hammer.js library for this . Here's what I sketched, but for now I can't
var myElement = document.getElementById('bottom-arrow'); var hammertime = new Hammer(myElement); hammertime.on('swipe', function(ev) { console.log(ev); $(this).toggleClass('toggled'); $('#fix-bot').toggle('slow'); }); #bottom { position: fixed; width: 100%; bottom: 0; background: rgba(153, 0, 0, 0.8); text-align: center; } #fix-bot { height: 50px; } #fix-bot p { color: #fff; } #bottom-arrow { width: 100%; pointer-events: none; height: 23px; background: rgba(153, 0, 0, 0.8); } #bottom-arrow:before { pointer-events: all; content: "\f107"; font-family: 'FontAwesome'; color: #fff; font-size: 50px; font-weight: 400; line-height: 17px; transition: transform linear 0.5s; display: inline-block; } #bottom-arrow.toggled:before { content: "\f106"; } body { margin: 0; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/hammer.js/1.0.5/hammer.js"></script> <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <div id="bottom"> <div id="bottom-arrow"></div> <div id="fix-bot"> <p>Контейнер</p> </div> </div>
pointer-events: none;for#bottom-arrowfor which you want to make aswipe! - Ihor TkachukHammer.jsimportant forHammer.js? I took the first example I got from Docs and everything works jsfiddle.net/6ckv4xnn . Only swipe horizontal! - Ihor Tkachukmc.get('swipe').set({ direction: Hammer.DIRECTION_ALL });but something is not working. Search the docks! - Ihor Tkachuk