From 93834ad4ecca6feb22d220162986bcefa10c988e Mon Sep 17 00:00:00 2001 From: David Oliveros Date: Tue, 20 Oct 2015 11:52:37 -0500 Subject: [PATCH] Bumped version number --- bower.json | 2 +- dist/angular-smooth-scroll.min.js | 24 ++++++++--------- lib/angular-smooth-scroll.js | 44 +++++++++++++++---------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/bower.json b/bower.json index 701cea5..a800712 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ngSmoothScroll", - "version": "1.7.3", + "version": "1.7.4", "homepage": "https://github.com/d-oliveros/ngSmoothScroll", "authors": [ "David Oliveros " diff --git a/dist/angular-smooth-scroll.min.js b/dist/angular-smooth-scroll.min.js index d2cb1ce..ba678d5 100644 --- a/dist/angular-smooth-scroll.min.js +++ b/dist/angular-smooth-scroll.min.js @@ -1,16 +1,16 @@ /*! - * Angular Smooth Scroll (ngSmoothScroll) - * Animates scrolling to elements, by David Oliveros. - * + * Angular Smooth Scroll (ngSmoothScroll) + * Animates scrolling to elements, by David Oliveros. + * * Callback hooks contributed by Ben Armston https://github.com/benarmston - * Easing support contributed by Willem Liu. https://github.com/willemliu - * Easing functions forked from Gaëtan Renaudeau. https://gist.github.com/gre/1650294 - * Infinite loop bugs in iOS and Chrome (when zoomed) by Alex Guzman. https://github.com/alexguzman - * Support for scrolling in custom containers by Joseph Matthias Goh. https://github.com/zephinzer - * Influenced by Chris Ferdinandi - * https://github.com/cferdinandi + * Easing support contributed by Willem Liu. https://github.com/willemliu + * Easing functions forked from Gaëtan Renaudeau. https://gist.github.com/gre/1650294 + * Infinite loop bugs in iOS and Chrome (when zoomed) by Alex Guzman. https://github.com/alexguzman + * Support for scrolling in custom containers by Joseph Matthias Goh. https://github.com/zephinzer + * Influenced by Chris Ferdinandi + * https://github.com/cferdinandi * - * Version: 1.7.3 - * License: MIT + * Version: 1.7.4 + * License: MIT */ -!function(){"use strict";var e=angular.module("smoothScroll",[]),t=function(e,t){t=t||{};var n=t.duration||800,c=t.offset||0,r=t.easing||"easeInOutQuart",a=t.callbackBefore||function(){},o=t.callbackAfter||function(){},l=document.getElementById(t.containerId)||null,u=void 0!=l&&null!=l,f=function(){return u?l.scrollTop:window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},i=function(e,t){switch(e){case"easeInQuad":return t*t;case"easeOutQuad":return t*(2-t);case"easeInOutQuad":return.5>t?2*t*t:-1+(4-2*t)*t;case"easeInCubic":return t*t*t;case"easeOutCubic":return--t*t*t+1;case"easeInOutCubic":return.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1;case"easeInQuart":return t*t*t*t;case"easeOutQuart":return 1- --t*t*t*t;case"easeInOutQuart":return.5>t?8*t*t*t*t:1-8*--t*t*t*t;case"easeInQuint":return t*t*t*t*t;case"easeOutQuint":return 1+--t*t*t*t*t;case"easeInOutQuint":return.5>t?16*t*t*t*t*t:1+16*--t*t*t*t*t;default:return t}},s=function(e){var t=0;if(e.offsetParent)do t+=e.offsetTop,e=e.offsetParent;while(e);return t=Math.max(t-c,0)};setTimeout(function(){var t,c,d,b,k=null,m=f(),I=s(e),v=0,g=I-m,p=function(){k=f(),u?(d=l.scrollHeight,b=l.clientHeight+k):(d=document.body.scrollheight,b=window.innerHeight+k),(c==I||k==I||b>=d)&&(clearInterval(A),o(e))},h=function(){v+=16,t=v/n,t=t>1?1:t,c=m+g*i(r,t),u?l.scrollTop=c:window.scrollTo(0,c),p()};a(e);var A=setInterval(h,16)},0)};e.factory("smoothScroll",function(){return t}),e.directive("smoothScroll",["smoothScroll",function(e){return{restrict:"A",scope:{callbackBefore:"&",callbackAfter:"&"},link:function(t,n,c){("undefined"==typeof c.scrollIf||"true"===c.scrollIf)&&setTimeout(function(){var r=function(e){if(c.callbackBefore){var n=t.callbackBefore({element:e});"function"==typeof n&&n(e)}},a=function(e){if(c.callbackAfter){var n=t.callbackAfter({element:e});"function"==typeof n&&n(e)}};e(n[0],{duration:c.duration,offset:c.offset,easing:c.easing,callbackBefore:r,callbackAfter:a,containerId:c.containerId})},0)}}}]),e.directive("scrollTo",["smoothScroll",function(e){return{restrict:"A",scope:{callbackBefore:"&",callbackAfter:"&"},link:function(t,n,c){var r;n.on("click",function(n){if(n.preventDefault(),r=document.getElementById(c.scrollTo)){var a=function(e){if(c.callbackBefore){var n=t.callbackBefore({element:e});"function"==typeof n&&n(e)}},o=function(e){if(c.callbackAfter){var n=t.callbackAfter({element:e});"function"==typeof n&&n(e)}};return e(r,{duration:c.duration,offset:c.offset,easing:c.easing,callbackBefore:a,callbackAfter:o,containerId:c.containerId}),!1}})}}}])}(); \ No newline at end of file +!function(){"use strict";var e=angular.module("smoothScroll",[]),t=function(e,t){t=t||{};var n=t.duration||800,c=t.offset||0,r=t.easing||"easeInOutQuart",a=t.callbackBefore||function(){},o=t.callbackAfter||function(){},l=document.getElementById(t.containerId)||null,u=void 0!=l&&null!=l,f=function(){return u?l.scrollTop:window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},i=function(e,t){switch(e){case"easeInQuad":return t*t;case"easeOutQuad":return t*(2-t);case"easeInOutQuad":return.5>t?2*t*t:-1+(4-2*t)*t;case"easeInCubic":return t*t*t;case"easeOutCubic":return--t*t*t+1;case"easeInOutCubic":return.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1;case"easeInQuart":return t*t*t*t;case"easeOutQuart":return 1- --t*t*t*t;case"easeInOutQuart":return.5>t?8*t*t*t*t:1-8*--t*t*t*t;case"easeInQuint":return t*t*t*t*t;case"easeOutQuint":return 1+--t*t*t*t*t;case"easeInOutQuint":return.5>t?16*t*t*t*t*t:1+16*--t*t*t*t*t;default:return t}},s=function(e){var t=0;if(e.offsetParent)do t+=e.offsetTop,e=e.offsetParent;while(e);return t=Math.max(t-c,0)};setTimeout(function(){var t,c,d,b,k=null,m=f(),I=s(e),v=0,g=I-m,h=function(){k=f(),u?(d=l.scrollHeight,b=l.clientHeight+k):(d=document.body.scrollheight,b=window.innerHeight+k),c!=I&&k!=I&&d>b||(clearInterval(A),o(e))},p=function(){v+=16,t=v/n,t=t>1?1:t,c=m+g*i(r,t),u?l.scrollTop=c:window.scrollTo(0,c),h()};a(e);var A=setInterval(p,16)},0)};e.factory("smoothScroll",function(){return t}),e.directive("smoothScroll",["smoothScroll",function(e){return{restrict:"A",scope:{callbackBefore:"&",callbackAfter:"&"},link:function(t,n,c){(void 0===c.scrollIf||"true"===c.scrollIf)&&setTimeout(function(){var r=function(e){if(c.callbackBefore){var n=t.callbackBefore({element:e});"function"==typeof n&&n(e)}},a=function(e){if(c.callbackAfter){var n=t.callbackAfter({element:e});"function"==typeof n&&n(e)}};e(n[0],{duration:c.duration,offset:c.offset,easing:c.easing,callbackBefore:r,callbackAfter:a,containerId:c.containerId})},0)}}}]),e.directive("scrollTo",["smoothScroll",function(e){return{restrict:"A",scope:{callbackBefore:"&",callbackAfter:"&"},link:function(t,n,c){var r;n.on("click",function(n){if(n.preventDefault(),r=document.getElementById(c.scrollTo)){var a=function(e){if(c.callbackBefore){var n=t.callbackBefore({element:e});"function"==typeof n&&n(e)}},o=function(e){if(c.callbackAfter){var n=t.callbackAfter({element:e});"function"==typeof n&&n(e)}};return e(r,{duration:c.duration,offset:c.offset,easing:c.easing,callbackBefore:a,callbackAfter:o,containerId:c.containerId}),!1}})}}}])}(); \ No newline at end of file diff --git a/lib/angular-smooth-scroll.js b/lib/angular-smooth-scroll.js index 7799b8b..021661b 100644 --- a/lib/angular-smooth-scroll.js +++ b/lib/angular-smooth-scroll.js @@ -1,7 +1,7 @@ /*! * Angular Smooth Scroll (ngSmoothScroll) * Animates scrolling to elements, by David Oliveros. - * + * * Callback hooks contributed by Ben Armston https://github.com/benarmston * Easing support contributed by Willem Liu. https://github.com/willemliu * Easing functions forked from Gaëtan Renaudeau. https://gist.github.com/gre/1650294 @@ -10,7 +10,7 @@ * Influenced by Chris Ferdinandi * https://github.com/cferdinandi * - * Version: 1.7.3 + * Version: 1.7.4 * License: MIT */ @@ -22,13 +22,13 @@ /** * Smooth scrolls the window/div to the provided element. - * + * * 20150713 EDIT - zephinzer * Added new option - containerId to account for scrolling within a DIV */ var smoothScroll = function (element, options) { options = options || {}; - + // Options var duration = options.duration || 800, offset = options.offset || 0, @@ -37,7 +37,7 @@ callbackAfter = options.callbackAfter || function() {}, container = document.getElementById(options.containerId) || null, containerPresent = (container != undefined && container != null); - + /** * Retrieve current location */ @@ -52,10 +52,10 @@ } } }; - + /** * Calculate easing pattern. - * + * * 20150713 edit - zephinzer * - changed if-else to switch * @see http://archive.oreilly.com/pub/a/server-administration/excerpts/even-faster-websites/writing-efficient-javascript.html @@ -77,7 +77,7 @@ default: return time; } }; - + /** * Calculate how far to scroll */ @@ -92,7 +92,7 @@ location = Math.max(location - offset, 0); return location; }; - + // Initialize the whole thing setTimeout( function() { var currentLocation = null, @@ -100,7 +100,7 @@ endLocation = getEndLocation(element), timeLapsed = 0, distance = endLocation - startLocation, - percentage, + percentage, position, scrollHeight, internalHeight; @@ -117,17 +117,17 @@ scrollHeight = document.body.scrollheight; internalHeight = window.innerHeight + currentLocation; } - - if ( + + if ( ( // condition 1 position == endLocation - ) || + ) || ( // condition 2 currentLocation == endLocation - ) || + ) || ( // condition 3 - internalHeight >= scrollHeight - ) + internalHeight >= scrollHeight + ) ) { // stop clearInterval(runAnimation); callbackAfter(element); @@ -161,11 +161,11 @@ module.factory('smoothScroll', function() { return smoothScroll; }); - + /** * Scrolls the window to this element, optionally validating an expression - * + * * 20150713 EDIT - zephinzer * Added containerId to attributes for smooth scrolling within a DIV */ @@ -217,7 +217,7 @@ * Scrolls to a specified element ID when this element is clicked * * 20150713 EDIT - zephinzer - * Added containerId to attributes for smooth scrolling within a DIV + * Added containerId to attributes for smooth scrolling within a DIV */ module.directive('scrollTo', ['smoothScroll', function(smoothScroll) { return { @@ -228,13 +228,13 @@ }, link: function($scope, $elem, $attrs) { var targetElement; - + $elem.on('click', function(e) { e.preventDefault(); targetElement = document.getElementById($attrs.scrollTo); - if ( !targetElement ) return; - + if ( !targetElement ) return; + var callbackBefore = function(element) { if ( $attrs.callbackBefore ) { var exprHandler = $scope.callbackBefore({element: element});