New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-snapscroll

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-snapscroll - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

bower.json
{
"name": "angular-snapscroll",
"version": "1.0.1",
"version": "1.0.2",
"authors": [

@@ -5,0 +5,0 @@ "Joel Mukuthu <joelmukuthu@gmail.com>"

@@ -0,1 +1,15 @@

## 1.0.2
### Fixes
- On trackpads with high sensitivity (e.g. Macs), swiping once does not lead to
a double snap anymore (thanks https://github.com/reco). There's a 1 second delay
that prevents the next snap, which can be changed (or disabled) with
[`prevent-double-snap-delay`](DOCS.md#prevent-double-snap-delay)
## 1.0.1
## Fixes
- Do not translate left/right scroll to up/down scroll
(https://github.com/joelmukuthu/angular-snapscroll/issues/37)
## 1.0.0

@@ -2,0 +16,0 @@

/**
* angular-snapscroll
* Version: 1.0.1
* Version: 1.0.2
* (c) 2014-2016 Joel Mukuthu
* MIT License
* Built on: 05-11-2016 18:17:30 GMT+0100
* Built on: 10-11-2016 11:54:12 GMT+0100
**/

@@ -16,3 +16,4 @@

.value('defaultSnapscrollResizeDelay', 400)
.value('defaultSnapscrollBindScrollTimeout', 400);
.value('defaultSnapscrollBindScrollTimeout', 400)
.value('defaultSnapscrollPreventDoubleSnapDelay', 1000);
})();

@@ -112,2 +113,3 @@

'defaultSnapscrollBindScrollTimeout',
'defaultSnapscrollPreventDoubleSnapDelay',
function (

@@ -121,3 +123,4 @@ $timeout,

defaultSnapscrollSnapDuration,
defaultSnapscrollBindScrollTimeout
defaultSnapscrollBindScrollTimeout,
defaultSnapscrollPreventDoubleSnapDelay
) {

@@ -269,5 +272,23 @@ return {

bindScrollAfterDelay();
allowNextSnapAfterDelay();
});
}
function allowNextSnapAfterDelay() {
function allowNextSnap() {
scope.preventUp = false;
scope.preventDown = false;
}
if (scope.preventUp || scope.preventDown) {
if (scope.preventDoubleSnapDelay === false) {
allowNextSnap();
} else {
$timeout(
allowNextSnap,
scope.preventDoubleSnapDelay
);
}
}
}
function isScrollable() {

@@ -417,3 +438,3 @@ var snapHeight = getSnapHeight();

function snap(direction) {
function snap(direction, source) {
if (!isScrollable()) {

@@ -423,2 +444,5 @@ return;

direction === 'up' && (scope.preventDown = false);
direction === 'down' && (scope.preventUp = false);
if (scope.snapDirection === direction) {

@@ -428,2 +452,6 @@ return true;

if (scope.preventUp || scope.preventDown) {
return true;
}
var snapIndex = scope.compositeIndex[0];

@@ -444,2 +472,7 @@ var innerSnapIndex = scope.compositeIndex[1];

if (source === 'wheel') {
direction === 'up' && (scope.preventUp = true);
direction === 'down' && (scope.preventDown = true);
}
scope.$apply(function () {

@@ -450,11 +483,12 @@ scope.compositeIndex = rectifyCompositeIndex(

});
return true;
}
function snapUp() {
return snap('up');
function snapUp(source) {
return snap('up', source);
}
function snapDown() {
return snap('down');
function snapDown(source) {
return snap('down', source);
}

@@ -466,3 +500,3 @@

e.preventDefault();
if (snapUp()) {
if (snapUp('wheel')) {
e.stopPropagation();

@@ -473,3 +507,3 @@ }

e.preventDefault();
if (snapDown()) {
if (snapDown('wheel')) {
e.stopPropagation();

@@ -675,2 +709,20 @@ }

var preventDoubleSnapDelay = (
attributes.preventDoubleSnapDelay
);
if (preventDoubleSnapDelay === 'false') {
scope.preventDoubleSnapDelay = false;
} else {
preventDoubleSnapDelay = parseInt(
preventDoubleSnapDelay,
10
);
if (isNaN(preventDoubleSnapDelay)) {
preventDoubleSnapDelay = (
defaultSnapscrollPreventDoubleSnapDelay
);
}
scope.preventDoubleSnapDelay = preventDoubleSnapDelay;
}
var snapEasing = attributes.snapEasing;

@@ -677,0 +729,0 @@ if (isDefined(snapEasing)) {

@@ -1,2 +0,2 @@

/* angular-snapscroll v1.0.1, (c) 2014-2016 Joel Mukuthu, MIT License, built: 05-11-2016 18:17:30 GMT+0100 */
!function(){angular.module("snapscroll",["wheelie","scrollie"]).value("defaultSnapscrollScrollEasing",void 0).value("defaultSnapscrollScrollDelay",250).value("defaultSnapscrollSnapDuration",800).value("defaultSnapscrollResizeDelay",400).value("defaultSnapscrollBindScrollTimeout",400)}(),function(){angular.module("snapscroll").directive("fitWindowHeight",["$window","$timeout","defaultSnapscrollResizeDelay",function(a,b,c){return{restrict:"A",require:"snapscroll",link:function(d,e,f,g){function h(){l===!1?g.setSnapHeight(a.innerHeight):(b.cancel(k),k=b(function(){g.setSnapHeight(a.innerHeight)},l))}function i(){"false"===l?l=!1:(l=parseInt(l,10),isNaN(l)&&(l=c)),g.setSnapHeight(a.innerHeight),j=angular.element(a),j.on("resize",h),d.$on("$destroy",function(){j.off("resize")})}var j,k,l=f.resizeDelay;i()}}}])}(),function(){function a(a){return angular.isNumber(a)&&!isNaN(a)}var b=angular.isDefined,c=angular.isUndefined,d=angular.isFunction,e=angular.forEach,f={enabled:"=snapscroll",snapIndex:"=?",snapHeight:"=?",beforeSnap:"&",afterSnap:"&",snapAnimation:"=?"},g=["$scope",function(a){this.setSnapHeight=function(b){a.snapHeight=b}}],h=["$timeout","$document","wheelie","scrollie","defaultSnapscrollScrollEasing","defaultSnapscrollScrollDelay","defaultSnapscrollSnapDuration","defaultSnapscrollBindScrollTimeout",function(h,i,j,k,l,m,n,o){return{restrict:"A",scope:f,controller:g,link:function(f,g,p){function q(){return g.children()}function r(a){return a.offsetHeight}function s(a){return r(q()[a])}function t(){return r(g[0])}function u(){return g[0].scrollHeight}function v(a){var b=u()-t();return a>b?b:a}function w(a,c){for(var d=a[0],e=a[1],f=0,g=q(),h=0;h<d;h++)f+=r(g[h]);if(0===e)return v(f);var i,j=t(),k=r(g[d]);if(b(c)&&e<c[1]){i=k;for(var l=e;l>=0;l--)i-=j}else{i=0;for(var m=0;m<e;m++)i+=j;var n=i+j-k;n>0&&(i-=n)}return v(f+i)}function x(d,e){var g=d[0],h=c(e)||g!==e[0];if(h){var i=f.beforeSnap({snapIndex:g});if(i===!1)return void(b(e)&&(f.ignoreCompositeIndexChange=!0,f.compositeIndex=e));if(a(i))return void(f.snapIndex=i)}return z(w(d,e)).then(function(){h&&f.afterSnap({snapIndex:g})})}function y(){return g[0].scrollTop}function z(a){var b;b=f.snapAnimation?c(f.snapEasing)?[g,a,f.snapDuration]:[g,a,f.snapDuration,f.snapEasing]:[g,a];var d=y();return a>d?f.snapDirection="down":a<d?f.snapDirection="up":f.snapDirection="same",X(),k.to.apply(k,b).then(function(){f.snapDirection=void 0,Y()})}function A(){var a=t();if(!a)return!1;var b=q();if(!b.length)return!1;var c=0;return e(b,function(a){c+=r(a)}),!(c<a)}function B(a){return a>=0&&a<=q().length-1}function C(b,d){if(A())return c(b)?void(f.snapIndex=0):a(b)?b%1!==0?void(f.snapIndex=Math.round(b)):f.ignoreSnapIndexChange===!0?void(f.ignoreSnapIndexChange=void 0):B(b)?void(f.compositeIndex=[b,0]):(B(d)||(d=0),f.ignoreSnapIndexChange=!0,void(f.snapIndex=d)):(a(d)||(d=0),void(f.snapIndex=d))}function D(){f.unwatchSnapIndex=f.$watch("snapIndex",C)}function E(){d(f.unwatchSnapIndex)&&(f.unwatchSnapIndex(),f.unwatchSnapIndex=void 0)}function F(a,b){if(!c(a)){var d=a[0];return f.snapIndex!==d&&(f.ignoreSnapIndexChange=!0,f.snapIndex=d),f.ignoreCompositeIndexChange===!0?void(f.ignoreCompositeIndexChange=void 0):void x(a,b)}}function G(){f.unwatchCompositeIndex=f.$watchCollection("compositeIndex",F)}function H(){d(f.unwatchCompositeIndex)&&(f.unwatchCompositeIndex(),f.unwatchCompositeIndex=void 0)}function I(a){var b=t(),c=s(a);if(c<=b)return 0;var d=parseInt(c/b,10);return c%b===0&&(d-=1),d}function J(a){var b=a[0],c=a[1];return c<0?B(b-1):!(c>I(b))||B(b+1)}function K(a){var b=a[0],c=a[1];return c<0?[b-1,I(b-1)]:c>I(b)?[b+1,0]:a}function L(a){if(A()){if(f.snapDirection===a)return!0;var b,c=f.compositeIndex[0],d=f.compositeIndex[1];"up"===a&&(b=d-1),"down"===a&&(b=d+1);var e=[c,b];if(J(e))return f.$apply(function(){f.compositeIndex=K(e)}),!0}}function M(){return L("up")}function N(){return L("down")}function O(){j.bind(g,{up:function(a){a.preventDefault(),M()&&a.stopPropagation()},down:function(a){a.preventDefault(),N()&&a.stopPropagation()}})}function P(){j.unbind(g)}function Q(a,b){a.css("height",b+"px")}function R(d,h){if(!c(d)){if(!a(d))return void(a(h)&&(f.snapHeight=h));Q(g,d),e(q(),function(a){Q(angular.element(a),d)}),b(f.snapIndex)&&(c(f.compositeIndex)&&(f.compositeIndex=[f.snapIndex,0]),x(f.compositeIndex))}}function S(){f.unwatchSnapHeight=f.$watch("snapHeight",R)}function T(){d(f.unwatchSnapHeight)&&(f.unwatchSnapHeight(),f.unwatchSnapHeight=void 0)}function U(a){var b=0,c=0;if(a>0){b=-1;for(var d,e=q();a>0;)d=r(e[++b]),a-=d;var f=t();if(d>f){for(a+=d-f,a>=f&&c++;a>0;)c++,a-=f;f/2>=-a&&(c+=1)}else d/2>=-a&&(b+=1)}return K([b,c])}function V(){function a(){var a=U(y());f.compositeIndex[0]===a[0]&&f.compositeIndex[1]===a[1]?x(f.compositeIndex):f.$apply(function(){f.compositeIndex=a})}k.stop(g),f.scrollDelay===!1?a():(h.cancel(f.scrollPromise),f.scrollPromise=h(function(){a(),f.scrollPromise=void 0},f.scrollDelay))}function W(){if(!f.preventSnappingAfterManualScroll&&!f.scrollBound){if(b(f.snapDirection))return void Y();g.on("scroll",V),f.scrollBound=!0}}function X(){f.scrollBound&&(g.off("scroll",V),f.scrollBound=!1)}function Y(){f.preventSnappingAfterManualScroll||(f.bindScrollPromise&&h.cancel(f.bindScrollPromise),f.bindScrollPromise=h(function(){W(),f.bindScrollPromise=void 0},o))}function Z(a){a.originalEvent&&(a=a.originalEvent);var b,c=a.keyCode;38===c&&(b=M),40===c&&(b=N),b&&(a.preventDefault(),b())}function $(){f.enableArrowKeys&&!f.arrowKeysBound&&(i.on("keydown",Z),f.arrowKeysBound=!0)}function _(){f.arrowKeysBound&&(i.off("keydown",Z),f.arrowKeysBound=!1)}function aa(){var a=p.scrollDelay;"false"===a?f.scrollDelay=!1:(a=parseInt(a,10),isNaN(a)&&(a=m),f.scrollDelay=a);var e=p.snapEasing;b(e)?f.snapEasing=f.$parent.$eval(e):d(l)&&(f.snapEasing=l);var h=parseInt(p.snapDuration,10);isNaN(h)&&(h=n),f.snapDuration=h,c(f.snapAnimation)&&(f.snapAnimation=!0),f.enableArrowKeys=b(p.enableArrowKeys),f.preventSnappingAfterManualScroll=b(p.preventSnappingAfterManualScroll),"scroll"!==g.css("overflowY")&&g.css("overflowY","auto"),f.$watch("enabled",function(a,b){function c(){f.preventSnappingAfterManualScroll||(f.compositeIndex=U(y()))}a!==!1?(b===!1&&c(),G(),D(),S(),W(),O(),$()):(H(),E(),T(),X(),P(),_())}),f.$on("$destroy",function(){f.enabled!==!1&&(X(),P(),_())})}aa()}}}];angular.module("snapscroll").directive("snapscroll",h)}();
/* angular-snapscroll v1.0.2, (c) 2014-2016 Joel Mukuthu, MIT License, built: 10-11-2016 11:54:12 GMT+0100 */
!function(){angular.module("snapscroll",["wheelie","scrollie"]).value("defaultSnapscrollScrollEasing",void 0).value("defaultSnapscrollScrollDelay",250).value("defaultSnapscrollSnapDuration",800).value("defaultSnapscrollResizeDelay",400).value("defaultSnapscrollBindScrollTimeout",400).value("defaultSnapscrollPreventDoubleSnapDelay",1e3)}(),function(){angular.module("snapscroll").directive("fitWindowHeight",["$window","$timeout","defaultSnapscrollResizeDelay",function(a,b,c){return{restrict:"A",require:"snapscroll",link:function(d,e,f,g){function h(){l===!1?g.setSnapHeight(a.innerHeight):(b.cancel(k),k=b(function(){g.setSnapHeight(a.innerHeight)},l))}function i(){"false"===l?l=!1:(l=parseInt(l,10),isNaN(l)&&(l=c)),g.setSnapHeight(a.innerHeight),j=angular.element(a),j.on("resize",h),d.$on("$destroy",function(){j.off("resize")})}var j,k,l=f.resizeDelay;i()}}}])}(),function(){function a(a){return angular.isNumber(a)&&!isNaN(a)}var b=angular.isDefined,c=angular.isUndefined,d=angular.isFunction,e=angular.forEach,f={enabled:"=snapscroll",snapIndex:"=?",snapHeight:"=?",beforeSnap:"&",afterSnap:"&",snapAnimation:"=?"},g=["$scope",function(a){this.setSnapHeight=function(b){a.snapHeight=b}}],h=["$timeout","$document","wheelie","scrollie","defaultSnapscrollScrollEasing","defaultSnapscrollScrollDelay","defaultSnapscrollSnapDuration","defaultSnapscrollBindScrollTimeout","defaultSnapscrollPreventDoubleSnapDelay",function(h,i,j,k,l,m,n,o,p){return{restrict:"A",scope:f,controller:g,link:function(f,g,q){function r(){return g.children()}function s(a){return a.offsetHeight}function t(a){return s(r()[a])}function u(){return s(g[0])}function v(){return g[0].scrollHeight}function w(a){var b=v()-u();return a>b?b:a}function x(a,c){for(var d=a[0],e=a[1],f=0,g=r(),h=0;h<d;h++)f+=s(g[h]);if(0===e)return w(f);var i,j=u(),k=s(g[d]);if(b(c)&&e<c[1]){i=k;for(var l=e;l>=0;l--)i-=j}else{i=0;for(var m=0;m<e;m++)i+=j;var n=i+j-k;n>0&&(i-=n)}return w(f+i)}function y(d,e){var g=d[0],h=c(e)||g!==e[0];if(h){var i=f.beforeSnap({snapIndex:g});if(i===!1)return void(b(e)&&(f.ignoreCompositeIndexChange=!0,f.compositeIndex=e));if(a(i))return void(f.snapIndex=i)}return A(x(d,e)).then(function(){h&&f.afterSnap({snapIndex:g})})}function z(){return g[0].scrollTop}function A(a){var b;b=f.snapAnimation?c(f.snapEasing)?[g,a,f.snapDuration]:[g,a,f.snapDuration,f.snapEasing]:[g,a];var d=z();return a>d?f.snapDirection="down":a<d?f.snapDirection="up":f.snapDirection="same",Z(),k.to.apply(k,b).then(function(){f.snapDirection=void 0,$(),B()})}function B(){function a(){f.preventUp=!1,f.preventDown=!1}(f.preventUp||f.preventDown)&&(f.preventDoubleSnapDelay===!1?a():h(a,f.preventDoubleSnapDelay))}function C(){var a=u();if(!a)return!1;var b=r();if(!b.length)return!1;var c=0;return e(b,function(a){c+=s(a)}),!(c<a)}function D(a){return a>=0&&a<=r().length-1}function E(b,d){if(C())return c(b)?void(f.snapIndex=0):a(b)?b%1!==0?void(f.snapIndex=Math.round(b)):f.ignoreSnapIndexChange===!0?void(f.ignoreSnapIndexChange=void 0):D(b)?void(f.compositeIndex=[b,0]):(D(d)||(d=0),f.ignoreSnapIndexChange=!0,void(f.snapIndex=d)):(a(d)||(d=0),void(f.snapIndex=d))}function F(){f.unwatchSnapIndex=f.$watch("snapIndex",E)}function G(){d(f.unwatchSnapIndex)&&(f.unwatchSnapIndex(),f.unwatchSnapIndex=void 0)}function H(a,b){if(!c(a)){var d=a[0];return f.snapIndex!==d&&(f.ignoreSnapIndexChange=!0,f.snapIndex=d),f.ignoreCompositeIndexChange===!0?void(f.ignoreCompositeIndexChange=void 0):void y(a,b)}}function I(){f.unwatchCompositeIndex=f.$watchCollection("compositeIndex",H)}function J(){d(f.unwatchCompositeIndex)&&(f.unwatchCompositeIndex(),f.unwatchCompositeIndex=void 0)}function K(a){var b=u(),c=t(a);if(c<=b)return 0;var d=parseInt(c/b,10);return c%b===0&&(d-=1),d}function L(a){var b=a[0],c=a[1];return c<0?D(b-1):!(c>K(b))||D(b+1)}function M(a){var b=a[0],c=a[1];return c<0?[b-1,K(b-1)]:c>K(b)?[b+1,0]:a}function N(a,b){if(C()){if("up"===a&&(f.preventDown=!1),"down"===a&&(f.preventUp=!1),f.snapDirection===a)return!0;if(f.preventUp||f.preventDown)return!0;var c,d=f.compositeIndex[0],e=f.compositeIndex[1];"up"===a&&(c=e-1),"down"===a&&(c=e+1);var g=[d,c];if(L(g))return"wheel"===b&&("up"===a&&(f.preventUp=!0),"down"===a&&(f.preventDown=!0)),f.$apply(function(){f.compositeIndex=M(g)}),!0}}function O(a){return N("up",a)}function P(a){return N("down",a)}function Q(){j.bind(g,{up:function(a){a.preventDefault(),O("wheel")&&a.stopPropagation()},down:function(a){a.preventDefault(),P("wheel")&&a.stopPropagation()}})}function R(){j.unbind(g)}function S(a,b){a.css("height",b+"px")}function T(d,h){if(!c(d)){if(!a(d))return void(a(h)&&(f.snapHeight=h));S(g,d),e(r(),function(a){S(angular.element(a),d)}),b(f.snapIndex)&&(c(f.compositeIndex)&&(f.compositeIndex=[f.snapIndex,0]),y(f.compositeIndex))}}function U(){f.unwatchSnapHeight=f.$watch("snapHeight",T)}function V(){d(f.unwatchSnapHeight)&&(f.unwatchSnapHeight(),f.unwatchSnapHeight=void 0)}function W(a){var b=0,c=0;if(a>0){b=-1;for(var d,e=r();a>0;)d=s(e[++b]),a-=d;var f=u();if(d>f){for(a+=d-f,a>=f&&c++;a>0;)c++,a-=f;f/2>=-a&&(c+=1)}else d/2>=-a&&(b+=1)}return M([b,c])}function X(){function a(){var a=W(z());f.compositeIndex[0]===a[0]&&f.compositeIndex[1]===a[1]?y(f.compositeIndex):f.$apply(function(){f.compositeIndex=a})}k.stop(g),f.scrollDelay===!1?a():(h.cancel(f.scrollPromise),f.scrollPromise=h(function(){a(),f.scrollPromise=void 0},f.scrollDelay))}function Y(){if(!f.preventSnappingAfterManualScroll&&!f.scrollBound){if(b(f.snapDirection))return void $();g.on("scroll",X),f.scrollBound=!0}}function Z(){f.scrollBound&&(g.off("scroll",X),f.scrollBound=!1)}function $(){f.preventSnappingAfterManualScroll||(f.bindScrollPromise&&h.cancel(f.bindScrollPromise),f.bindScrollPromise=h(function(){Y(),f.bindScrollPromise=void 0},o))}function _(a){a.originalEvent&&(a=a.originalEvent);var b,c=a.keyCode;38===c&&(b=O),40===c&&(b=P),b&&(a.preventDefault(),b())}function aa(){f.enableArrowKeys&&!f.arrowKeysBound&&(i.on("keydown",_),f.arrowKeysBound=!0)}function ba(){f.arrowKeysBound&&(i.off("keydown",_),f.arrowKeysBound=!1)}function ca(){var a=q.scrollDelay;"false"===a?f.scrollDelay=!1:(a=parseInt(a,10),isNaN(a)&&(a=m),f.scrollDelay=a);var e=q.preventDoubleSnapDelay;"false"===e?f.preventDoubleSnapDelay=!1:(e=parseInt(e,10),isNaN(e)&&(e=p),f.preventDoubleSnapDelay=e);var h=q.snapEasing;b(h)?f.snapEasing=f.$parent.$eval(h):d(l)&&(f.snapEasing=l);var i=parseInt(q.snapDuration,10);isNaN(i)&&(i=n),f.snapDuration=i,c(f.snapAnimation)&&(f.snapAnimation=!0),f.enableArrowKeys=b(q.enableArrowKeys),f.preventSnappingAfterManualScroll=b(q.preventSnappingAfterManualScroll),"scroll"!==g.css("overflowY")&&g.css("overflowY","auto"),f.$watch("enabled",function(a,b){function c(){f.preventSnappingAfterManualScroll||(f.compositeIndex=W(z()))}a!==!1?(b===!1&&c(),I(),F(),U(),Y(),Q(),aa()):(J(),G(),V(),Z(),R(),ba())}),f.$on("$destroy",function(){f.enabled!==!1&&(Z(),R(),ba())})}ca()}}}];angular.module("snapscroll").directive("snapscroll",h)}();

@@ -206,1 +206,16 @@ # angular-snapscroll docs

```
#### prevent-double-snap-delay
In order to prevent snapping twice in the same direction on trackpads with high
sensitivity, there is a 1 second delay that disables snapping to the same
direction. This can be altered using this attribute or disabled altogether by
passing `false`.
```html
<div snapscroll="" prevent-double-snap-delay="400"> ... </div>
```
the scroll-delay can also be changed for all snapscroll instances by changing
the default value:
```javascript
angular.module('myapp', ['snapscroll'])
.value('defaultSnapscrollPreventDoubleSnapDelay', 400);
```
{
"name": "angular-snapscroll",
"version": "1.0.1",
"version": "1.0.2",
"description": "Vertical scroll-and-snap functionality in angular",

@@ -5,0 +5,0 @@ "main": "dist/angular-snapscroll.js",

@@ -15,3 +15,3 @@ # angular-snapscroll

```sh
bower install angular-snapscroll angular-wheelie angular-scrollie
bower install angular-snapscroll
```

@@ -84,8 +84,2 @@ Or with npm:

### Known issue and workaround
Swiping on a trackpad with high sensitivity (i.e. on a Mac) may cause a snapscroll
instance to snap twice in the same direction. The workaround for this is to set
`defaultSnapscrollSnapDuration` or `snap-duration` to a higher value (try 1000ms
or 1200ms).
### Todo's

@@ -95,3 +89,2 @@ - snapscroll as an element - would allow use of templates and ngAnimate for

this.
- more browser tests

@@ -98,0 +91,0 @@ ### Contributing

@@ -35,2 +35,3 @@ (function () {

'defaultSnapscrollBindScrollTimeout',
'defaultSnapscrollPreventDoubleSnapDelay',
function (

@@ -44,3 +45,4 @@ $timeout,

defaultSnapscrollSnapDuration,
defaultSnapscrollBindScrollTimeout
defaultSnapscrollBindScrollTimeout,
defaultSnapscrollPreventDoubleSnapDelay
) {

@@ -192,5 +194,23 @@ return {

bindScrollAfterDelay();
allowNextSnapAfterDelay();
});
}
function allowNextSnapAfterDelay() {
function allowNextSnap() {
scope.preventUp = false;
scope.preventDown = false;
}
if (scope.preventUp || scope.preventDown) {
if (scope.preventDoubleSnapDelay === false) {
allowNextSnap();
} else {
$timeout(
allowNextSnap,
scope.preventDoubleSnapDelay
);
}
}
}
function isScrollable() {

@@ -340,3 +360,3 @@ var snapHeight = getSnapHeight();

function snap(direction) {
function snap(direction, source) {
if (!isScrollable()) {

@@ -346,2 +366,5 @@ return;

direction === 'up' && (scope.preventDown = false);
direction === 'down' && (scope.preventUp = false);
if (scope.snapDirection === direction) {

@@ -351,2 +374,6 @@ return true;

if (scope.preventUp || scope.preventDown) {
return true;
}
var snapIndex = scope.compositeIndex[0];

@@ -367,2 +394,7 @@ var innerSnapIndex = scope.compositeIndex[1];

if (source === 'wheel') {
direction === 'up' && (scope.preventUp = true);
direction === 'down' && (scope.preventDown = true);
}
scope.$apply(function () {

@@ -373,11 +405,12 @@ scope.compositeIndex = rectifyCompositeIndex(

});
return true;
}
function snapUp() {
return snap('up');
function snapUp(source) {
return snap('up', source);
}
function snapDown() {
return snap('down');
function snapDown(source) {
return snap('down', source);
}

@@ -389,3 +422,3 @@

e.preventDefault();
if (snapUp()) {
if (snapUp('wheel')) {
e.stopPropagation();

@@ -396,3 +429,3 @@ }

e.preventDefault();
if (snapDown()) {
if (snapDown('wheel')) {
e.stopPropagation();

@@ -598,2 +631,20 @@ }

var preventDoubleSnapDelay = (
attributes.preventDoubleSnapDelay
);
if (preventDoubleSnapDelay === 'false') {
scope.preventDoubleSnapDelay = false;
} else {
preventDoubleSnapDelay = parseInt(
preventDoubleSnapDelay,
10
);
if (isNaN(preventDoubleSnapDelay)) {
preventDoubleSnapDelay = (
defaultSnapscrollPreventDoubleSnapDelay
);
}
scope.preventDoubleSnapDelay = preventDoubleSnapDelay;
}
var snapEasing = attributes.snapEasing;

@@ -600,0 +651,0 @@ if (isDefined(snapEasing)) {

@@ -8,3 +8,4 @@ (function () {

.value('defaultSnapscrollResizeDelay', 400)
.value('defaultSnapscrollBindScrollTimeout', 400);
.value('defaultSnapscrollBindScrollTimeout', 400)
.value('defaultSnapscrollPreventDoubleSnapDelay', 1000);
})();

@@ -37,4 +37,7 @@ describe('Module: snapscroll', function () {

it('defaultSnapscrollPreventDoubleSnapDelay', inject(function (defaultSnapscrollPreventDoubleSnapDelay) {
expect(angular.isNumber(defaultSnapscrollPreventDoubleSnapDelay)).toBe(true);
}));
});
});

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc