Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

return if object no longer exists in the DOM

  • Loading branch information...
commit 21eaf6949d82aedc9b90df9e00c33e39818ecbbb 1 parent 8e309e6
Zack Kitzmiller zackkitzmiller authored
Showing with 5 additions and 2 deletions.
  1. +4 −1 jquery.sap.js
  2. +1 −1  jquery.sap.min.js
5 jquery.sap.js
View
@@ -1,11 +1,12 @@
/**
- * Sap v1.0.3
+ * Sap v1.0.4
*
* Inspired by Contained Sticky Scroll v1.1 By Matt Ward
* http://blog.echoenduring.com/2010/11/15/freebie-contained-sticky-scroll-jquery-plugin/
*
* (c) 2011 Forrst, LLC
*/
+
(function($) {
$.fn.sap = function(options) {
@@ -18,6 +19,8 @@
var $objizzle = $(this);
+ if (!$objizzle.length) return;
+
var oldTop = $objizzle.offset().top;
var width = $objizzle.width() + 'px';
var $shim = $('<div class="sap-shimy-shim"></div>');
2  jquery.sap.min.js
View
@@ -1 +1 @@
-(function(a){a.fn.sap=function(d){var i={distanceFromTheTop:0};d=a.extend(i,d);var h=a(this);var b=h.offset().top;var e=h.width()+"px";var g=a('<div class="sap-shimy-shim"></div>');var f=a(window);var c=a(document);f.scroll(function(){var j=f.scrollTop();if((j+d.distanceFromTheTop+h.height())<(c.height()-f.height())&&(j+d.distanceFromTheTop)>h.offset().top){h.css({position:"fixed",width:e,top:d.distanceFromTheTop+"px"});g.css({width:e,height:h.height()});h.before(g)}else{if(j+d.distanceFromTheTop<b){g.remove();h.css({position:"static",width:e,top:""})}}})}}(jQuery));
+(function($){$.fn.sap=function(options){var defaults={distanceFromTheTop:0};options=$.extend(defaults,options);var $objizzle=$(this);if(!$objizzle.length)return;var oldTop=$objizzle.offset().top;var width=$objizzle.width()+'px';var $shim=$('<div class="sap-shimy-shim"></div>');var theWindow=$(window);var theDoc=$(document);theWindow.scroll(function(){var top=theWindow.scrollTop();if((top+options.distanceFromTheTop+$objizzle.height())<(theDoc.height()-theWindow.height())&&(top+options.distanceFromTheTop)>$objizzle.offset().top){$objizzle.css({position:'fixed',width:width,top:options.distanceFromTheTop+'px'});$shim.css({width:width,height:$objizzle.height()});$objizzle.before($shim)}else if(top+options.distanceFromTheTop<oldTop){$shim.remove();$objizzle.css({position:'static',width:width,top:''})}})}}(jQuery));
Please sign in to comment.
Something went wrong with that request. Please try again.