Skip to content

Commit 7a2a297

Browse files
committed
User jQuerys scrollTop instead of scrollY for IE 10 compatibility
1 parent fffde92 commit 7a2a297

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jquery.pin.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
(function ($) {
22
"use strict";
33
$.fn.pin = function (options) {
4-
var scrollY = 0, elements = [], disabled = false;
4+
var scrollY = 0, elements = [], disabled = false, $window = $(window);
55

66
options = options || {};
77

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

12-
if (options.minWidth && $(window).width() <= options.minWidth) {
12+
if (options.minWidth && $window.width() <= options.minWidth) {
1313
if ($this.parent().is(".pin-wrapper")) { $this.unwrap(); }
1414
$this.css({width: "", left: "", top: "", position: ""});
1515
disabled = true;
@@ -42,7 +42,7 @@
4242
var onScroll = function () {
4343
if (disabled) { return; }
4444

45-
scrollY = window.scrollY;
45+
scrollY = $window.scrollTop();
4646

4747
for (var i=0, len=elements.length; i<len; i++) {
4848
var $this = $(elements[i]),
@@ -84,11 +84,11 @@
8484
$(this).data('pin', data);
8585
});
8686

87-
$(window).scroll(onScroll);
88-
$(window).resize(function () { recalculateLimits(); });
87+
$window.scroll(onScroll);
88+
$window.resize(function () { recalculateLimits(); });
8989
recalculateLimits();
9090

91-
$(window).load(update);
91+
$window.load(update);
9292

9393
return this;
9494
};

0 commit comments

Comments
 (0)