simplify touch detection logic

no swipes on desktop needed with the previous commit!
This commit is contained in:
Lorenz Hübschle-Schneider 2017-04-17 18:04:09 +02:00 committed by Lorenz Hübschle-Schneider
parent 6b7b639618
commit 1c71ede145
2 changed files with 7 additions and 9 deletions

View file

@ -280,7 +280,7 @@ npm run build-electron-{windows, darwin, linux}</pre>
</a>
</div>
</div>
<div id="sidebar" data-state="visible" ng-swipe-left="swipeLeft($event)" class="vertical-line">
<div id="sidebar" data-state="visible" ng-swipe-left="swipeLeft()" ng-swipe-disable-mouse class="vertical-line">
<ul class="nav nav-pills nav-stacked" ng-class="{'indented': (predicate === 'serverSortKey'), 'showquickkeys': showQuickKeys, 'showjumpkeys': showJumpKeys}">
<li class="bufferfilter">
<form role="form">
@ -310,8 +310,8 @@ npm run build-electron-{windows, darwin, linux}</pre>
</li>
</ul>
</div>
<div id="bufferlines" class="favorite-font" ng-swipe-right="swipeRight($event)" ng-swipe-left="swipeLeft($event)" ng-class="{'withnicklist': showNicklist}" when-scrolled="infiniteScroll()" imgur-drop>
<div id="nicklist" ng-if="showNicklist" ng-swipe-right="closeNick()" class="vertical-line-left">
<div id="bufferlines" class="favorite-font" ng-swipe-right="swipeRight()" ng-swipe-left="swipeLeft()" ng-swipe-disable-mouse ng-class="{'withnicklist': showNicklist}" when-scrolled="infiniteScroll()" imgur-drop>
<div id="nicklist" ng-if="showNicklist" ng-swipe-right="swipeRight()" ng-swipe-disable-mouse class="vertical-line-left">
<ul class="nicklistgroup list-unstyled" ng-repeat="group in nicklist">
<li ng-repeat="nick in group.nicks|orderBy:'name'">
<a ng-click="openBuffer(nick.name)"><span ng-class="::nick.prefixClasses" ng-bind="::nick.prefix"></span><span ng-class="::nick.nameClasses" ng-bind="::nick.name"></span></a>

View file

@ -332,13 +332,12 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
return document.getElementById('content').getAttribute('sidebar-state') === 'visible';
};
$scope.swipeRight = function($event) {
var touch = $event instanceof TouchEvent;
$scope.swipeRight = function() {
// Depending on swipe state
if ($scope.swipeStatus === 1) {
/* do nothing */
} else if ($scope.swipeStatus === 0) {
if (touch) $scope.showSidebar();
$scope.showSidebar();
} else if ($scope.swipeStatus === -1) {
if (!settings.alwaysnicklist) $scope.closeNick();
} else {
@ -349,11 +348,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}
};
$rootScope.swipeLeft = function($event) {
var touch = $event instanceof TouchEvent;
$rootScope.swipeLeft = function() {
// Depending on swipe state, ...
if ($scope.swipeStatus === 1) {
if (touch) $scope.hideSidebar();
$scope.hideSidebar();
} else if ($scope.swipeStatus === 0) {
$scope.openNick();
} else if ($scope.swipeStatus === -1) {