Permalink
Browse files

Fixed #121

1 parent 322c607 commit d33ae4515be21a76bb7907c94dd8a0ca0de7e49b @flesler committed Sep 24, 2015
Showing with 96 additions and 88 deletions.
  1. +91 −83 CHANGELOG → CHANGELOG.md
  2. +2 −2 jquery.scrollTo.js
  3. +2 −2 jquery.scrollTo.min.js
  4. +1 −1 package.json
@@ -1,177 +1,185 @@
-2.1.1
-[Fix]
+# Changelog
+
+## 2.1.2
+### Fix
+- Plugin won't break if an empty jQuery object is passed, it's now consistent with selector target #121
+### Docs
+- Converted the CHANGELOG to Markdown
+
+## 2.1.1
+### Fix
- Slight change so define function is not minified (#91)
-2.1.0
-[Enhancement]
+## 2.1.0
+### Enhancement
- Avoid animating a needless axis
-[Feature]
+### Feature
- Implemented interrupt setting, if true will stop animating on user (manual) scroll (#67)
-2.0.1
-[Fix]
+## 2.0.1
+### Fix
- Fixed "queue" setting conflicts with $().animate(), forced to always get there as true
-2.0.0
-[Feature]
+## 2.0.0
+### Feature
- All settings are passed to jQuery.animate() meaning it now supports even more settings
-[Enhancement]
+### Enhancement
- $(window)._scrollable() is no longer needed, the element is always the window
- Delegating to jQuery the get/set of element/window scroll positions.
-[Compat]
+### Compat
- Dropped support for $.scrollTo.window() and $(window)._scrollable()
-[Fix]
+### Fix
- Now works consistenly on Chrome 40
- Now works correctly on Windows Phone
- Now works correctly on Android Browsers
- Now works correctly on iOS Browsers
-1.4.14
-[Misc]
+## 1.4.14
+###Misc
- Internal both() function will handle nulls correctly
-1.4.13
-[Misc]
+## 1.4.13
+###Misc
- Support for CommonJS / NPM added by durango
-1.4.12
-[Fix]
+## 1.4.12
+### Fix
- Fixed selector matching body fails on window scrolling
-1.4.11
-[Misc]
-- Reverted changes from 1.4.10
+## 1.4.11
+###Misc
+##- Reverted changes from 1.4.10
-1.4.10
-[Enhancement]
+## 1.4.10
+### Enhancement
- Giving the plugin an AMD module id so it can be required (f.e by localScroll)
-1.4.9
-[Enhancement]
+## 1.4.9
+### Enhancement
- "offset" setting can now be a function as well (#60)
-1.4.8
-[Enhancement]
+## 1.4.8
+### Enhancement
- Added support for AMD
-1.4.7
-[Misc]
+## 1.4.7
+###Misc
- Changed spacing
- Changed licensing to MIT
- Repo is compliant with official jquery plugins repository
-1.4.6
-[Fix]
+## 1.4.6
+### Fix
- Fixed first argument of onAfter and onAfterFirst was original target and should be "parsed" target
-1.4.5
-[Fix]
+## 1.4.5
+### Fix
- Fixed passing a negative scroll value crashes
-1.4.4
-[Change]
-- Re-released as 1.4.4 to avoid issues with bower
+## 1.4.4
+###Change
+##- Re-released as 1.4.4 to avoid issues with bower
-1.4.3.1
-[Fix]
-- Fixed $.scrollTo(0) broken on 1.4.3
+## 1.4.3.1
+### Fix
+##- Fixed $.scrollTo(0) broken on 1.4.3
-1.4.3
-[Enhancement]
+## 1.4.3
+### Enhancement
- Limit calculations can be disabled by setting the option 'limit' to false.
- Null target or unmatching selector don't break and fail silently
-[Misc]
+###Misc
- Removed support for the deprecated setting 'speed'
-[Fix]
-- Removed $.browser.webkit so the plugin works with jQuery +1.8
+### Fix
+##- Removed $.browser.webkit so the plugin works with jQuery +1.8
-1.4.2
-[Feature]
+## 1.4.2
+### Feature
- The plugin support percentages as target ('50%' or {top:'50%', left:'45%'})
- Exposed the max() calculation as $.scrollTo.max
-[Enhancement]
+### Enhancement
- Renamed $.fn.scrollable to $.fn._scrollable to avoid conflicts with other plugins
-[Fix]
+### Fix
- Fixing max calculations for regular DOM elements
-1.4.1
-[Feature]
+## 1.4.1
+### Feature
- The target can be 'max' to scroll to the end while keeping it elegant.
-[Enhancement]
-- Default duration is 0 for jquery +1.3. Means sync animation
+### Enhancement
+##- Default duration is 0 for jquery +1.3. Means sync animation
- The plugin works on all major browsers, on compat & quirks modes, including iframes.
- In addition to window/document, if html or body are received, the plugin will choose the right one.
-[Fix]
+### Fix
- The plugin accepts floating numbers, Thanks Ramin
- Using jQuery.nodeName where neccessary so that this works on xml+xhtml
- The max() internal function wasn't completely accurrate, now it is 98% (except for IE on quirks mode and it's not too noticeable).
-1.4
-[Fix]
+## 1.4
+### Fix
- Fixed the problem when scrolling the window to absolute positioned elements on Safari.
- Fixed the problem on Opera 9.5 when scrolling the window. That it always scrolls to 0.
-[Feature]
+### Feature
- Added the settings object as 2nd argument to the onAfter callback.
- The 3rd argument of scrollTo can be just a function and it's used as the onAfter.
- Added full support for iframes (even max scroll calculation).
- Instead of $.scrollTo, $(window).scrollTo() and $(document).scrollTo() can be used.
-- Added $().scrollable() that returns the real element to scroll, f.e: $(window).scrollable() == [body|html], works for iframes.
-[Enhancement]
+- Added $().scrollable() that returns the real element to scroll, f.e: $(window).scrollable() == ###body|html], works for iframes
+### Enhancement
- Cleaned the code a bit, specially the comments
-1.3.3
-[Change]
+## 1.3.3
+###Change
- Changed the licensing from GPL to GPL+MIT.
-1.3.2
-[Enhancement]
+## 1.3.2
+### Enhancement
- Small improvements to make the code shorter.
-[Change]
+###Change
- Removed the last argument received by onAfter as it was the same as the 'this' but jqueryfied.
-1.3.1
-[Feature]
+## 1.3.1
+### Feature
- Exposed $.scrollTo.window() to get the element that needs to be animated, to scroll the window.
- Added option 'over'.
-[Enhancement]
+### Enhancement
- Made the code as short as possible.
-[Change]
+###Change
- Changed the arguments received by onAfter
-1.3
-[Enhancement]
+## 1.3
+### Enhancement
- Added semicolon to the start, for safe file concatenation
- Added a limit check, values below 0 or over the maximum are fixed.
- Now it should work faster, only one of html or body go through all the processing, instead of both for all browsers.
-[Fix]
+### Fix
- Fixed the behavior for Opera, which seemed to react to both changes on <html> and <body>.
- The border is also reduced, when 'margin' is set to true.
-[Change]
+###Change
- The option speed has been renamed to duration.
-[Feature]
+### Feature
- The duration can be specified with a number as 2nd argument, and the rest of the settings as the third ( like $().animate )
- Remade the demo
-1.2.4
-[Enhancement]
+#### 1.2.4
+### Enhancement
- The target can be in the form of { top:x, left:y } allowing different position for each axis.
-[Feature]
+### Feature
- The option 'offset' has been added, to scroll behind or past the target. Can be a number(both axes) or { top:x, left:y }.
-1.2.3
-[Feature]
+#### 1.2.3
+### Feature
- Exposed the defaults.
-[Enhancement]
+### Enhancement
- Made the callback functions receive more parameters.
-1.2.2
-[Fix]
+#### 1.2.2
+### Fix
- Fixed a bug, I didn't have to add the scrolled amount if it was body or html.
-1.2
-[Change]
+## 1.2
+###Change
- The option 'onafter' is now called 'onAfter'.
-[Feature]
+### Feature
- Two axes can be scrolled together, this is set with the option 'axis'.
- In case 2 axes are chosen, the scrolling can be queued: one scrolls, and then the other.
- There's an intermediary event, 'onAfterFirst' called in case the axes are queued, after the first ends.
View
@@ -5,7 +5,7 @@
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
* @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
* @author Ariel Flesler
- * @version 2.1.1
+ * @version 2.1.2
*/
;(function(factory) {
'use strict';
@@ -83,9 +83,9 @@
}
// Relative/Absolute selector
targ = win ? $(targ) : $(targ, elem);
- if (!targ.length) return;
/* falls through */
case 'object':
+ if (targ.length === 0) return;
// DOMElement / jQuery
if (targ.is || targ.style) {
// Get the real position of the target
@@ -2,6 +2,6 @@
* Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* @author Ariel Flesler
- * @version 2.1.1
+ * @version 2.1.2
*/
-;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);if(!e.length)return;case "object":if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});
+;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);case "object":if(e.length===0)return;if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});
View
@@ -1,6 +1,6 @@
{
"name": "jquery.scrollto",
- "version": "2.1.1",
+ "version": "2.1.2",
"description": "Lightweight, cross-browser and highly customizable animated scrolling with jQuery",
"main": "jquery.scrollTo.js",
"license": "MIT",

0 comments on commit d33ae45

Please sign in to comment.