Skip to content

Commit

Permalink
remove unless indexOf function
Browse files Browse the repository at this point in the history
need to rebuild
  • Loading branch information
afc163 committed Jun 25, 2013
1 parent ba440d6 commit beb015c
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ define(function (require, exports, module) {
this.callback.call(this, false);
};

// 需要占位符的情况有: 1) position: static or relative; 但除了 display 不是 block
// 需要占位符的情况有: 1) position: static or relative,除了 display 不是 block 的情况
Sticky.prototype._addPlaceholder = function() {
var need = false;
var position = this.elem.css("position");

if (indexOf(["static", "relative"], this.elem.css("position")) !== -1) {
if (position === 'static' || position === 'relative') {
need = true;
}
if (this.elem.css("display") !== "block") {
Expand Down Expand Up @@ -256,13 +257,4 @@ define(function (require, exports, module) {
}
}

function indexOf(array, item) {
if (array == null) return -1;
var nativeIndexOf = Array.prototype.indexOf;

if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
for (var i = 0; i < array.length; i++) if (array[i] === item) return i;
return -1;
}

});

0 comments on commit beb015c

Please sign in to comment.