Skip to content

Commit 18b6ff3

Browse files
author
Pablo Largo Mohedano
committed
Some refactoring suggested by JSHint
1 parent 9ed1680 commit 18b6ff3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

parallax.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
var vendors = ['ms', 'moz', 'webkit', 'o'];
1515
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
1616
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
17-
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
18-
|| window[vendors[x]+'CancelRequestAnimationFrame'];
17+
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
1918
}
2019

2120
if (!window.requestAnimationFrame)
@@ -65,8 +64,8 @@
6564
positions = [positions[1], positions[0]];
6665
}
6766

68-
if (this.positionX != undefined) positions[0] = this.positionX.toLowerCase();
69-
if (this.positionY != undefined) positions[1] = this.positionY.toLowerCase();
67+
if (this.positionX !== undefined) positions[0] = this.positionX.toLowerCase();
68+
if (this.positionY !== undefined) positions[1] = this.positionY.toLowerCase();
7069

7170
self.positionX = positions[0];
7271
self.positionY = positions[1];
@@ -154,7 +153,7 @@
154153
this.$slider.trigger('load');
155154
}
156155

157-
};
156+
}
158157

159158

160159
// Parallax Instance Methods
@@ -181,13 +180,14 @@
181180
var minOffset = Math.max(this.boxOffsetTop + this.boxHeight - winHeight, 0);
182181
var imageHeightMin = this.boxHeight + (maxOffset - minOffset) * (1 - this.speed) | 0;
183182
var imageOffsetMin = (this.boxOffsetTop - maxOffset) * (1 - this.speed) | 0;
183+
var margin;
184184

185185
if (imageHeightMin * this.aspectRatio >= this.boxWidth) {
186186
this.imageWidth = imageHeightMin * this.aspectRatio | 0;
187187
this.imageHeight = imageHeightMin;
188188
this.offsetBaseTop = imageOffsetMin;
189189

190-
var margin = this.imageWidth - this.boxWidth;
190+
margin = this.imageWidth - this.boxWidth;
191191

192192
if (this.positionX == 'left') {
193193
this.offsetLeft = 0;
@@ -203,7 +203,7 @@
203203
this.imageHeight = this.boxWidth / this.aspectRatio | 0;
204204
this.offsetLeft = 0;
205205

206-
var margin = this.imageHeight - imageHeightMin;
206+
margin = this.imageHeight - imageHeightMin;
207207

208208
if (this.positionY == 'top') {
209209
this.offsetBaseTop = imageOffsetMin;
@@ -314,7 +314,7 @@
314314
},
315315

316316
refresh: function() {
317-
$.each(this.sliders, function(){ this.refresh() });
317+
$.each(this.sliders, function(){ this.refresh(); });
318318
this.isFresh = true;
319319
},
320320

@@ -373,13 +373,13 @@
373373
}
374374
if (typeof option == 'string') {
375375
if(option == 'destroy'){
376-
Parallax['destroy'](this);
376+
Parallax.destroy(this);
377377
}else{
378378
Parallax[option]();
379379
}
380380
}
381-
})
382-
};
381+
});
382+
}
383383

384384
var old = $.fn.parallax;
385385

0 commit comments

Comments
 (0)