Skip to content

Commit

Permalink
User jQuerys scrollTop instead of scrollY for IE 10 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
biilmann committed Mar 26, 2013
1 parent fffde92 commit 7a2a297
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions jquery.pin.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(function ($) {
"use strict";
$.fn.pin = function (options) {
var scrollY = 0, elements = [], disabled = false;
var scrollY = 0, elements = [], disabled = false, $window = $(window);

options = options || {};

var recalculateLimits = function () {
for (var i=0, len=elements.length; i<len; i++) {
var $this = elements[i];

if (options.minWidth && $(window).width() <= options.minWidth) {
if (options.minWidth && $window.width() <= options.minWidth) {
if ($this.parent().is(".pin-wrapper")) { $this.unwrap(); }
$this.css({width: "", left: "", top: "", position: ""});
disabled = true;
Expand Down Expand Up @@ -42,7 +42,7 @@
var onScroll = function () {
if (disabled) { return; }

scrollY = window.scrollY;
scrollY = $window.scrollTop();

for (var i=0, len=elements.length; i<len; i++) {
var $this = $(elements[i]),
Expand Down Expand Up @@ -84,11 +84,11 @@
$(this).data('pin', data);
});

$(window).scroll(onScroll);
$(window).resize(function () { recalculateLimits(); });
$window.scroll(onScroll);
$window.resize(function () { recalculateLimits(); });
recalculateLimits();

$(window).load(update);
$window.load(update);

return this;
};
Expand Down

0 comments on commit 7a2a297

Please sign in to comment.