Permalink
Browse files

Fixed conflicted setting with .animate(), updated demo

  • Loading branch information...
1 parent b85b356 commit 1b0bd67bc9c7f328606181e49719f7ae2fbc3022 @flesler committed Mar 18, 2015
Showing with 157 additions and 127 deletions.
  1. +1 −1 bower.json
  2. +4 −0 changes.txt
  3. +16 −9 demo/css/style.css
  4. +126 −109 demo/index.html
  5. +7 −5 jquery.scrollTo.js
  6. +2 −2 jquery.scrollTo.min.js
  7. +1 −1 package.json
View
@@ -1,6 +1,6 @@
{
"name": "jquery.scrollTo",
- "version": "2.0.0",
+ "version": "2.0.1",
"description": "Easy element scrolling using jQuery.",
"homepage": "https://github.com/flesler/jquery.scrollTo",
"main": [
View
@@ -1,3 +1,7 @@
+2.0.1
+[Fix]
+- Fixed "queue" setting conflicts with $().animate(), forced to always get there as true
+
2.0.0
[Feature]
- All settings are passed to jQuery.animate() meaning it now supports even more settings
View
@@ -4,7 +4,7 @@ body{
font-family: Verdana, sans-serif;
background-color: #DDD;
}
-ul,li,h1,h2,h3,p{
+ul,li,h1,h2,h3,h4,p{
list-style:none;
padding:0;
margin:0;
@@ -13,7 +13,9 @@ ul,li,h1,h2,h3,p{
border:1px solid black;
background-color:white;
}
- .part h3{
+ .part h3,
+ .part h4,
+ .part h4 a {
color:#933;
}
#toc{
@@ -59,21 +61,25 @@ ul,li,h1,h2,h3,p{
#toc a{
color:#69C;
}
-div.section{
+.section{
border:1px black solid;
width:950px;
padding:10px;
margin: 5px 0;
position:relative;
clear:both;
}
- div.section h3{
+ .section h3{
margin-bottom:10px;
+ margin-left: 8px;
}
- div.section li{
+ .section h4{
+ margin:10px 0 10px 8px;
+ }
+ .section li{
float:left;
}
- div.pane{
+ .pane{
overflow:auto;
clear:left;
margin: 10px 0 0 10px;
@@ -104,19 +110,20 @@ ul.elements{
ul.elements li p{
color:#666;
}
- #pane-options ul.elements li{
+ #pane-settings ul.elements li{
margin:5px;
}
- #pane-options{
+ #pane-settings{
margin-bottom:10px;
}
ul.links{
height:20px;
overflow:hidden;
+ padding-left: 5px;
}
ul.links a{
color:#69C;
- margin:0pt 5px;
+ margin:0 0 0 5px;
}
.clear{
clear:left;
View
Oops, something went wrong.
View
@@ -5,7 +5,7 @@
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
* @projectDescription Easy element scrolling using jQuery.
* @author Ariel Flesler
- * @version 2.0.0
+ * @version 2.0.1
*/
;(function(define) {
'use strict';
@@ -42,9 +42,8 @@
// Speed is still recognized for backwards compatibility
duration = duration || settings.duration;
// Make sure the settings are given right
- settings.queue = settings.queue && settings.axis.length > 1;
-
- if (settings.queue) {
+ var queue = settings.queue && settings.axis.length > 1;
+ if (queue) {
// Let's keep the overall duration
duration /= 2;
}
@@ -122,7 +121,7 @@
}
// Queueing axes
- if (!i && settings.queue) {
+ if (!i && queue) {
// Don't waste time animating, if there's no need.
if (prev !== attr[key]) {
// Intermediate animation
@@ -137,6 +136,9 @@
function animate(callback) {
var opts = $.extend({}, settings, {
+ // The queue setting conflicts with animate()
+ // Force it to always be true
+ queue: true,
duration: duration,
complete: callback && function() {
callback.call(elem, targ, settings);
@@ -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.0.0
+ * @version 2.0.1
*/
-;(function(k){'use strict';k(['jquery'],function($){var j=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};j.defaults={axis:'xy',duration:0,limit:true};function isWin(a){return!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!==-1}$.fn.scrollTo=function(f,g,h){if(typeof g==='object'){h=g;g=0}if(typeof h==='function'){h={onAfter:h}}if(f==='max'){f=9e9}h=$.extend({},j.defaults,h);g=g||h.duration;h.queue=h.queue&&h.axis.length>1;if(h.queue){g/=2}h.offset=both(h.offset);h.over=both(h.over);return this.each(function(){if(f===null)return;var d=isWin(this),elem=d?this.contentWindow||window:this,$elem=$(elem),targ=f,attr={},toff;switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=d?$(targ):$(targ,elem);if(!targ.length)return;case'object':if(targ.is||targ.style){toff=(targ=$(targ)).offset()}}var e=$.isFunction(h.offset)&&h.offset(elem,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a==='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,prev=$(elem)[key](),max=j.max(elem,a);if(toff){attr[key]=toff[pos]+(d?0:prev-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b),10)||0;attr[key]-=parseInt(targ.css('border'+b+'Width'),10)||0}attr[key]+=e[pos]||0;if(h.over[pos]){attr[key]+=targ[a==='x'?'width':'height']()*h.over[pos]}}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)==='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key])){attr[key]=attr[key]<=0?0:Math.min(attr[key],max)}if(!i&&h.queue){if(prev!==attr[key]){animate(h.onAfterFirst)}attr={}}});animate(h.onAfter);function animate(a){var b=$.extend({},h,{duration:g,complete:a&&function(){a.call(elem,targ,h)}});$elem.animate(attr,b)}})};j.max=function(a,b){var c=b==='x'?'Width':'Height',scroll='scroll'+c;if(!isWin(a))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,doc=a.ownerDocument||a.document,html=doc.documentElement,body=doc.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(t){return $(t.elem)[t.prop]()},set:function(t){var v=Math.round(t.now);if(this.get(t)!==v){$(t.elem)[t.prop](v)}}};return j})}(typeof define==='function'&&define.amd?define:function(a,b){'use strict';if(typeof module!=='undefined'&&module.exports){module.exports=b(require('jquery'))}else{b(jQuery)}}));
+;(function(l){'use strict';l(['jquery'],function($){var k=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};k.defaults={axis:'xy',duration:0,limit:true};function isWin(a){return!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!==-1}$.fn.scrollTo=function(f,g,h){if(typeof g==='object'){h=g;g=0}if(typeof h==='function'){h={onAfter:h}}if(f==='max'){f=9e9}h=$.extend({},k.defaults,h);g=g||h.duration;var j=h.queue&&h.axis.length>1;if(j){g/=2}h.offset=both(h.offset);h.over=both(h.over);return this.each(function(){if(f===null)return;var d=isWin(this),elem=d?this.contentWindow||window:this,$elem=$(elem),targ=f,attr={},toff;switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=d?$(targ):$(targ,elem);if(!targ.length)return;case'object':if(targ.is||targ.style){toff=(targ=$(targ)).offset()}}var e=$.isFunction(h.offset)&&h.offset(elem,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a==='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,prev=$(elem)[key](),max=k.max(elem,a);if(toff){attr[key]=toff[pos]+(d?0:prev-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b),10)||0;attr[key]-=parseInt(targ.css('border'+b+'Width'),10)||0}attr[key]+=e[pos]||0;if(h.over[pos]){attr[key]+=targ[a==='x'?'width':'height']()*h.over[pos]}}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)==='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key])){attr[key]=attr[key]<=0?0:Math.min(attr[key],max)}if(!i&&j){if(prev!==attr[key]){animate(h.onAfterFirst)}attr={}}});animate(h.onAfter);function animate(a){var b=$.extend({},h,{queue:true,duration:g,complete:a&&function(){a.call(elem,targ,h)}});$elem.animate(attr,b)}})};k.max=function(a,b){var c=b==='x'?'Width':'Height',scroll='scroll'+c;if(!isWin(a))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,doc=a.ownerDocument||a.document,html=doc.documentElement,body=doc.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(t){return $(t.elem)[t.prop]()},set:function(t){var v=Math.round(t.now);if(this.get(t)!==v){$(t.elem)[t.prop](v)}}};return k})}(typeof define==='function'&&define.amd?define:function(a,b){'use strict';if(typeof module!=='undefined'&&module.exports){module.exports=b(require('jquery'))}else{b(jQuery)}}));
View
@@ -1,6 +1,6 @@
{
"name": "jquery.scrollto",
- "version": "2.0.0",
+ "version": "2.0.1",
"description": "Easy element scrolling using jQuery.",
"main": "jquery.scrollTo.js",
"license": "MIT",

0 comments on commit 1b0bd67

Please sign in to comment.