From c8467c069746e0e169368ab11143e2379267a5f3 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 10 Feb 2015 01:02:23 +0800 Subject: [PATCH] fix bug on window refresh --- jquery.pin.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/jquery.pin.js b/jquery.pin.js index 97d25c8..25521cb 100644 --- a/jquery.pin.js +++ b/jquery.pin.js @@ -33,13 +33,15 @@ bottom: 0 }, options.padding || {}); - $this.data("pin", { - pad: pad, - from: (options.containerSelector ? containerOffset.top : offset.top) - pad.top, - to: containerOffset.top + $container.height() - $this.outerHeight() - pad.bottom, - end: containerOffset.top + $container.height(), - parentTop: parentOffset.top - }); + if ($window.scrollTop() != offset.top) { + $this.data("pin", { + pad: pad, + from: (options.containerSelector ? containerOffset.top : offset.top) - pad.top, + to: containerOffset.top + $container.height() - $this.outerHeight() - pad.bottom, + end: containerOffset.top + $container.height(), + parentTop: parentOffset.top + }); + } $this.css({width: $this.outerWidth()}); $this.parent().css("height", $this.outerHeight());