angular-snapscroll
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "angular-snapscroll", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"authors": [ | ||
@@ -29,6 +29,6 @@ "Joel Mukuthu <joelmukuthu@gmail.com>" | ||
"angular": "^1.2.24", | ||
"angular-scrollie": "^1.0.0", | ||
"angular-wheelie": "^2.1.0" | ||
"angular-scrollie": "^1.1.1", | ||
"angular-wheelie": "^3.0.1" | ||
}, | ||
"homepage": "https://github.com/joelmukuthu/angular-snapscroll.git" | ||
} |
/** | ||
* angular-snapscroll | ||
* Version: 1.3.0 | ||
* Version: 1.3.1 | ||
* (c) 2014-2017 Joel Mukuthu | ||
* MIT License | ||
* Built on: 06-03-2017 12:22:02 GMT+0100 | ||
* Built on: 10-03-2017 17:26:46 GMT+0100 | ||
**/ | ||
@@ -8,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* angular-snapscroll v1.3.0, (c) 2014-2017 Joel Mukuthu, MIT License, built: 06-03-2017 12:22:02 GMT+0100 */ | ||
/* angular-snapscroll v1.3.1, (c) 2014-2017 Joel Mukuthu, MIT License, built: 10-03-2017 17:26:46 GMT+0100 */ | ||
"object"==typeof exports&&(module.exports="snapscroll"),angular.module("snapscroll",["wheelie","scrollie"]).value("defaultSnapscrollScrollEasing",void 0).value("defaultSnapscrollScrollDelay",250).value("defaultSnapscrollSnapDuration",800).value("defaultSnapscrollResizeDelay",400).value("defaultSnapscrollBindScrollTimeout",400).value("defaultSnapscrollPreventDoubleSnapDelay",1e3),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()}}}]),angular.module("snapscroll").directive("snapscroll",["$timeout","$document","wheelie","scrollie","defaultSnapscrollScrollEasing","defaultSnapscrollScrollDelay","defaultSnapscrollSnapDuration","defaultSnapscrollBindScrollTimeout","defaultSnapscrollPreventDoubleSnapDelay",function(a,b,c,d,e,f,g,h,i){function j(a){return angular.isNumber(a)&&!isNaN(a)}var k=angular.isDefined,l=angular.isUndefined,m=angular.isFunction,n=angular.forEach;return{restrict:"A",scope:{enabled:"=snapscroll",snapIndex:"=?",snapHeight:"=?",beforeSnap:"&",afterSnap:"&",snapAnimation:"=?"},controller:["$scope",function(a){this.setSnapHeight=function(b){a.snapHeight=b}}],link:function(o,p,q){function r(){return p.children()}function s(a){return a.offsetHeight}function t(a){return s(r()[a])}function u(){return s(p[0])}function v(){return p[0].scrollHeight}function w(a){var b=v()-u();return a>b?b:a}function x(a,b){for(var c=a[0],d=a[1],e=0,f=r(),g=0;g<c;g++)e+=s(f[g]);if(0===d)return w(e);var h,i=u(),j=s(f[c]);if(k(b)&&d<b[1]){h=j;for(var l=d;l>=0;l--)h-=i}else{h=0;for(var m=0;m<d;m++)h+=i;var n=h+i-j;n>0&&(h-=n)}return w(e+h)}function y(a,b){var c=a[0],d=l(b)||c!==b[0];if(d){var e=o.beforeSnap({snapIndex:c,$event:o.sourceEvent});if(e===!1)return void(k(b)&&(o.ignoreCompositeIndexChange=!0,o.compositeIndex=b));if(j(e))return void(o.snapIndex=e)}return A(x(a,b)).then(function(){d&&o.afterSnap({snapIndex:c,$event:o.sourceEvent}),o.sourceEvent=void 0})}function z(){return p[0].scrollTop}function A(a){var b;b=o.snapAnimation?l(o.snapEasing)?[p,a,o.snapDuration]:[p,a,o.snapDuration,o.snapEasing]:[p,a];var c=z();return o.snapDirection=a>c?"down":a<c?"up":"same",Z(),d.to.apply(d,b).then(function(){o.snapDirection=void 0,$(),B()})}function B(){function b(){o.preventUp=!1,o.preventDown=!1}(o.preventUp||o.preventDown)&&(o.preventDoubleSnapDelay===!1?b():a(b,o.preventDoubleSnapDelay))}function C(){var a=u();if(!a)return!1;var b=r();if(!b.length)return!1;var c=0;return n(b,function(a){c+=s(a)}),!(c<a)}function D(a){return a>=0&&a<=r().length-1}function E(a,b){if(C())return l(a)?void(o.snapIndex=0):j(a)?a%1!=0?void(o.snapIndex=Math.round(a)):o.ignoreSnapIndexChange===!0?void(o.ignoreSnapIndexChange=void 0):D(a)?void(o.compositeIndex=[a,0]):(D(b)||(b=0),o.ignoreSnapIndexChange=!0,void(o.snapIndex=b)):(j(b)||(b=0),void(o.snapIndex=b))}function F(){o.unwatchSnapIndex=o.$watch("snapIndex",E)}function G(){m(o.unwatchSnapIndex)&&(o.unwatchSnapIndex(),o.unwatchSnapIndex=void 0)}function H(a,b){if(!l(a)){var c=a[0];if(o.snapIndex!==c&&(o.ignoreSnapIndexChange=!0,o.snapIndex=c),o.ignoreCompositeIndexChange===!0)return void(o.ignoreCompositeIndexChange=void 0);y(a,b)}}function I(){o.unwatchCompositeIndex=o.$watchCollection("compositeIndex",H)}function J(){m(o.unwatchCompositeIndex)&&(o.unwatchCompositeIndex(),o.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&&(o.preventDown=!1),"down"===a&&(o.preventUp=!1),o.snapDirection===a)return!0;if(o.preventUp||o.preventDown)return!0;var c,d=o.compositeIndex[0],e=o.compositeIndex[1];"up"===a&&(c=e-1),"down"===a&&(c=e+1);var f=[d,c];if(L(f))return"wheel"===b.type&&("up"===a&&(o.preventUp=!0),"down"===a&&(o.preventDown=!0)),o.$apply(function(){o.sourceEvent=b,o.compositeIndex=M(f)}),!0}}function O(a){return N("up",a)}function P(a){return N("down",a)}function Q(){o.disableWheelBinding||o.wheelBound||(c.bind(p,{up:function(a){a.preventDefault(),O(a)&&a.stopPropagation()},down:function(a){a.preventDefault(),P(a)&&a.stopPropagation()}},o.ignoreWheelClass),o.wheelBound=!0)}function R(){o.wheelBound&&(c.unbind(p),o.wheelBound=!1)}function S(a,b){a.css("height",b+"px")}function T(a,b){if(!l(a)){if(!j(a))return void(j(b)&&(o.snapHeight=b));S(p,a),n(r(),function(b){S(angular.element(b),a)}),k(o.snapIndex)&&(l(o.compositeIndex)&&(o.compositeIndex=[o.snapIndex,0]),y(o.compositeIndex))}}function U(){o.unwatchSnapHeight=o.$watch("snapHeight",T)}function V(){m(o.unwatchSnapHeight)&&(o.unwatchSnapHeight(),o.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 b(){var a=W(z());o.compositeIndex[0]===a[0]&&o.compositeIndex[1]===a[1]?y(o.compositeIndex):o.$apply(function(){o.compositeIndex=a})}d.stop(p),o.scrollDelay===!1?b():(a.cancel(o.scrollPromise),o.scrollPromise=a(function(){b(),o.scrollPromise=void 0},o.scrollDelay))}function Y(){if(!o.preventSnappingAfterManualScroll&&!o.scrollBound){if(k(o.snapDirection))return void $();p.on("scroll",X),o.scrollBound=!0}}function Z(){o.scrollBound&&(p.off("scroll",X),o.scrollBound=!1)}function $(){o.preventSnappingAfterManualScroll||(o.bindScrollPromise&&a.cancel(o.bindScrollPromise),o.bindScrollPromise=a(function(){Y(),o.bindScrollPromise=void 0},h))}function _(a){a.originalEvent&&(a=a.originalEvent);var b,c=a.keyCode;38===c&&(b=O),40===c&&(b=P),b&&(a.preventDefault(),b(a))}function aa(){o.enableArrowKeys&&!o.arrowKeysBound&&(b.on("keydown",_),o.arrowKeysBound=!0)}function ba(){o.arrowKeysBound&&(b.off("keydown",_),o.arrowKeysBound=!1)}function ca(){var a=q.scrollDelay;"false"===a?o.scrollDelay=!1:(a=parseInt(a,10),isNaN(a)&&(a=f),o.scrollDelay=a);var b=q.preventDoubleSnapDelay;"false"===b?o.preventDoubleSnapDelay=!1:(b=parseInt(b,10),isNaN(b)&&(b=i),o.preventDoubleSnapDelay=b);var c=q.snapEasing;k(c)?o.snapEasing=o.$parent.$eval(c):m(e)&&(o.snapEasing=e);var d=parseInt(q.snapDuration,10);isNaN(d)&&(d=g),o.snapDuration=d,l(o.snapAnimation)&&(o.snapAnimation=!0),o.disableWheelBinding=k(q.disableWheelBinding),o.enableArrowKeys=k(q.enableArrowKeys),o.preventSnappingAfterManualScroll=k(q.preventSnappingAfterManualScroll),o.ignoreWheelClass=q.ignoreWheelClass,"scroll"!==p.css("overflowY")&&p.css("overflowY","auto"),o.$watch("enabled",function(a,b){function c(){o.preventSnappingAfterManualScroll||(o.compositeIndex=W(z()))}a!==!1?(b===!1&&c(),I(),F(),U(),Y(),Q(),aa()):(J(),G(),V(),Z(),R(),ba())}),o.$on("$destroy",function(){o.enabled!==!1&&(Z(),R(),ba())})}ca()}}}]); |
@@ -48,3 +48,3 @@ <!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<div ng-controller="MainCtrl"> | ||
<div snapscroll="" snapscroll="snapscrollEnabled"> ... </div> | ||
<div snapscroll="snapscrollEnabled"> ... </div> | ||
</div> | ||
@@ -127,2 +127,5 @@ ``` | ||
``` | ||
note that if you wish to ignore wheel events from an element with children, then | ||
the class-name must also be added to the child elements. that's because in this | ||
case wheel events will bubble from the child elements. | ||
@@ -129,0 +132,0 @@ ### before-snap |
{ | ||
"name": "angular-snapscroll", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Vertical scroll-and-snap functionality in angular", | ||
@@ -5,0 +5,0 @@ "main": "dist/angular-snapscroll.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273626