Skip to content

Commit

Permalink
Option to add and remove class to element being pinned as the pinning…
Browse files Browse the repository at this point in the history
… state changes. This allows CSS targeting based on if the element is being pinned or not.
  • Loading branch information
Mike Grace committed May 6, 2013
1 parent 7a2a297 commit 89aa497
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jquery.pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
if (options.minWidth && $window.width() <= options.minWidth) {
if ($this.parent().is(".pin-wrapper")) { $this.unwrap(); }
$this.css({width: "", left: "", top: "", position: ""});
if (options.activeClass) { $this.removeClass(options.activeClass); }
disabled = true;
continue;
} else {
Expand Down Expand Up @@ -60,13 +61,16 @@
left: $this.offset().left,
top: 0
}).css("position", "fixed");
if (options.activeClass) { $this.addClass(options.activeClass); }
} else if (scrollY >= to) {
$this.css({
left: "auto",
top: to - data.parentTop
}).css("position", "absolute");
if (options.activeClass) { $this.addClass(options.activeClass); }
} else {
$this.css({position: "", top: "", left: ""});
if (options.activeClass) { $this.removeClass(options.activeClass); }
}
}
};
Expand Down

0 comments on commit 89aa497

Please sign in to comment.