Skip to content
This repository was archived by the owner on Apr 15, 2020. It is now read-only.

Commit 0f26f24

Browse files
committed
Refactored snapDirection values to be more readable
1 parent f0d95e5 commit 0f26f24

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/directives/snapscroll.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
if (!scope.isValid(snapIndex)) {
6565
scope.ignoreThisSnapIndexChange = true;
6666
scope.snapIndex = previousSnapIndex;
67-
scope.snapDirection = 0;
67+
scope.snapDirection = 'none';
6868
return;
6969
}
7070
if (scope.beforeSnap({snapIndex: snapIndex}) === false) {
@@ -74,12 +74,12 @@
7474
}
7575
if (angular.isFunction(callback)) {
7676
if (snapIndex > previousSnapIndex) {
77-
scope.snapDirection = 1;
77+
scope.snapDirection = 'up';
7878
} else if (snapIndex < previousSnapIndex) {
79-
scope.snapDirection = -1;
79+
scope.snapDirection = 'down';
8080
}
8181
callback(snapIndex, function () {
82-
scope.snapDirection = 0;
82+
scope.snapDirection = 'none';
8383
scope.afterSnap({snapIndex: snapIndex});
8484
});
8585
}
@@ -96,7 +96,7 @@
9696
wheel.bind(element, {
9797
up: function (e) {
9898
var bubbleUp;
99-
if (scope.snapDirection !== -1) {
99+
if (scope.snapDirection !== 'down') {
100100
if (scope.snapIndex - 1 < scope.snapIndexMin()) {
101101
bubbleUp = true;
102102
} else {
@@ -110,7 +110,7 @@
110110
},
111111
down: function (e) {
112112
var bubbleUp;
113-
if (scope.snapDirection !== 1) {
113+
if (scope.snapDirection !== 'up') {
114114
if (scope.snapIndex + 1 > scope.scopeIndexMax()) {
115115
bubbleUp = true;
116116
} else {
@@ -199,7 +199,7 @@
199199

200200
bindScroll = function () {
201201
// if the bindScroll timeout expires while snapping is ongoing, restart the timer
202-
if (scope.snapDirection !== 0) {
202+
if (scope.snapDirection !== 'none') {
203203
bindScrollPromise = $timeout(bindScroll, defaultSnapscrollBindScrollTimeout);
204204
return;
205205
}

0 commit comments

Comments
 (0)