Skip to content

Commit

Permalink
Merge pull request #1757 from flashlab/patch-1
Browse files Browse the repository at this point in the history
Little trick enabling sidebar closing through swiping
  • Loading branch information
ivan-nginx authored Jul 11, 2017
2 parents 838a443 + 1abb546 commit afa67d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/js/src/motion.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ $(document).ready(function () {

var SIDEBAR_WIDTH = '320px';
var SIDEBAR_DISPLAY_DURATION = 200;
var xPos, yPos;

var sidebarToggleMotion = {
toggleEl: $('.sidebar-toggle'),
Expand All @@ -90,6 +91,9 @@ $(document).ready(function () {
this.dimmerEl.on('click', this.clickHandler.bind(this));
this.toggleEl.on('mouseenter', this.mouseEnterHandler.bind(this));
this.toggleEl.on('mouseleave', this.mouseLeaveHandler.bind(this));
this.sidebarEl.on('touchstart', this.touchstartHandler.bind(this));
this.sidebarEl.on('touchend', this.touchendHandler.bind(this));
this.sidebarEl.on('touchmove', function(e){e.preventDefault();});

$(document)
.on('sidebar.isShowing', function () {
Expand Down Expand Up @@ -117,6 +121,17 @@ $(document).ready(function () {
}
sidebarToggleLines.init();
},
touchstartHandler: function(e) {
xPos = e.originalEvent.touches[0].clientX;
yPos = e.originalEvent.touches[0].clientY;
},
touchendHandler: function(e) {
var _xPos = e.originalEvent.changedTouches[0].clientX;
var _yPos = e.originalEvent.changedTouches[0].clientY;
if (_xPos-xPos > 30 && Math.abs(_yPos-yPos) < 20) {
this.clickHandler();
}
},
showSidebar: function () {
var self = this;

Expand Down

0 comments on commit afa67d2

Please sign in to comment.