From 1eb59bcbb6ecfec324377467064b1a5775e2aae2 Mon Sep 17 00:00:00 2001 From: Arwid Bancewicz Date: Sun, 14 Aug 2011 05:30:08 -0400 Subject: [PATCH] Small fix. --- jquery.scrollIntoView.js | 5 ++++- jquery.scrollIntoView.min.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/jquery.scrollIntoView.js b/jquery.scrollIntoView.js index 5ee33b4..4f91870 100644 --- a/jquery.scrollIntoView.js +++ b/jquery.scrollIntoView.js @@ -38,10 +38,13 @@ // start from the common ancester var pEl = this.commonAncestor().get(0); + var wH = $(window).height(); + // go up parents until we find one that scrolls while (pEl) { var pY = pEl.scrollTop, pH = pEl.clientHeight; - + if (pH > wH) pH = wH; + if ( // it wiggles? (pEl.scrollTop != ((pEl.scrollTop += 1) == null || pEl.scrollTop) && (pEl.scrollTop -= 1) != null) || diff --git a/jquery.scrollIntoView.min.js b/jquery.scrollIntoView.min.js index 9207a67..163ff04 100644 --- a/jquery.scrollIntoView.min.js +++ b/jquery.scrollIntoView.min.js @@ -11,4 +11,4 @@ * @author Arwid Bancewicz http://arwid.ca * @version 0.2 */ -(function(a){a.fn.scrollIntoView=function(f,i,c){var b=a.extend({},a.fn.scrollIntoView.defaults);if(a.type(f)=="object"){a.extend(b,f)}else{if(a.type(f)=="number"){a.extend(b,{duration:f,easing:i,complete:c})}else{if(f==false){b.smooth=false}}}var g=Infinity,e=0;if(this.size()==1){((g=this.get(0).offsetTop)==null||(e=g+this.get(0).offsetHeight))}else{this.each(function(l){(l.offsetTope?e=l.offsetTop+l.offsetHeight:null)})}e-=g;var j=this.commonAncestor().get(0);while(j){var d=j.scrollTop,k=j.clientHeight;if((j.scrollTop!=((j.scrollTop+=1)==null||j.scrollTop)&&(j.scrollTop-=1)!=null)||(j.scrollTop!=((j.scrollTop-=1)==null||j.scrollTop)&&(j.scrollTop+=1)!=null)){if(g(d+k)){h(j,g+e-k)}}return}j=j.parentNode}function h(m,l){if(b.smooth){a(m).stop().animate({scrollTop:l},b)}else{m.scrollTop=g}}return this};a.fn.scrollIntoView.defaults={smooth:true,duration:null,easing:a.easing&&a.easing.easeOutExpo?"easeOutExpo":null,complete:a.noop(),step:null,specialEasing:null};a.fn.isOutOfView=function(b){var c=true;this.each(function(){var h=this.parentNode,d=h.scrollTop,g=h.clientHeight,f=this.offsetTop,e=this.offsetHeight;if(b?(f)>(d+g):(f+e)>(d+g)){}else{if(b?(f+e)e?e=m.offsetTop+m.offsetHeight:null)})}e-=h;var k=this.commonAncestor().get(0);var g=a(window).height();while(k){var d=k.scrollTop,l=k.clientHeight;if(l>g){l=g}if((k.scrollTop!=((k.scrollTop+=1)==null||k.scrollTop)&&(k.scrollTop-=1)!=null)||(k.scrollTop!=((k.scrollTop-=1)==null||k.scrollTop)&&(k.scrollTop+=1)!=null)){if(h(d+l)){i(k,h+e-l)}}return}k=k.parentNode}function i(n,m){if(b.smooth){a(n).stop().animate({scrollTop:m},b)}else{n.scrollTop=h}}return this};a.fn.scrollIntoView.defaults={smooth:true,duration:null,easing:a.easing&&a.easing.easeOutExpo?"easeOutExpo":null,complete:a.noop(),step:null,specialEasing:null};a.fn.isOutOfView=function(b){var c=true;this.each(function(){var h=this.parentNode,d=h.scrollTop,g=h.clientHeight,f=this.offsetTop,e=this.offsetHeight;if(b?(f)>(d+g):(f+e)>(d+g)){}else{if(b?(f+e)