Skip to content

Commit bff38e3

Browse files
committed
Further tweak IE fixes, make code pass JSHint
1 parent e4ef341 commit bff38e3

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

stellar.js

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
} else if ($.browser.mozilla) {
7373
prefix = '-moz-';
7474
} else if ($.browser.opera) {
75-
prefix = '-o-'
75+
prefix = '-o-';
7676
} else if ($.browser.msie) {
77-
prefix = '-ms-'
77+
prefix = '-ms-';
7878
}
7979

8080
return prefix;
@@ -322,6 +322,8 @@
322322
verticalOffset,
323323
positionLeft,
324324
positionTop,
325+
marginLeft,
326+
marginTop,
325327
offsetLeft,
326328
offsetTop;
327329

@@ -340,25 +342,9 @@
340342
$this.css('background-position', $this.data('stellar-backgroundStartingLeft') + ' ' + $this.data('stellar-backgroundStartingTop'));
341343
}
342344

343-
// Catch-all for margin left properties (this evaluates to 'auto' in IE7 and IE8)
344-
if($this.css('margin-left') == "auto")
345-
{
346-
marginLeft = parseInt("0px", 10);
347-
}
348-
else
349-
{
350-
marginLeft = parseInt($this.css('margin-left'), 10);
351-
}
352-
353-
// Catch-all for margin top properties (this evaluates to 'auto' in IE7 and IE8)
354-
if($this.css('margin-top') == "auto")
355-
{
356-
marginTop = parseInt("0px", 10);
357-
}
358-
else
359-
{
360-
marginTop = parseInt($this.css('margin-top'), 10);
361-
}
345+
// Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8)
346+
marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10);
347+
marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10);
362348

363349
offsetLeft = $this.offset().left - marginLeft - scrollLeft;
364350
offsetTop = $this.offset().top - marginTop - scrollTop;
@@ -388,9 +374,10 @@
388374
var particle,
389375
startingPositionLeft,
390376
startingPositionTop,
391-
background;
377+
background,
378+
i;
392379

393-
for (var i = this.particles.length - 1; i >= 0; i--) {
380+
for (i = this.particles.length - 1; i >= 0; i--) {
394381
particle = this.particles[i];
395382
startingPositionLeft = particle.$element.data('stellar-startingLeft');
396383
startingPositionTop = particle.$element.data('stellar-startingTop');
@@ -403,7 +390,7 @@
403390
particle.$element.data('stellar-startingLeft', null).data('stellar-elementIsActive', null).data('stellar-backgroundIsActive', null);
404391
}
405392

406-
for (var i = this.backgrounds.length - 1; i >= 0; i--) {
393+
for (i = this.backgrounds.length - 1; i >= 0; i--) {
407394
background = this.backgrounds[i];
408395
background.$element.css('background-position', background.startingValueLeft + ' ' + background.startingValueTop);
409396
}
@@ -449,7 +436,8 @@
449436
newPositionLeft,
450437
newPositionTop,
451438
newOffsetLeft,
452-
newOffsetTop;
439+
newOffsetTop,
440+
i;
453441

454442
//First check that the scroll position or container size has changed
455443
if (this.currentScrollLeft === scrollLeft && this.currentScrollTop === scrollTop && this.currentWidth === this.viewportWidth && this.currentHeight === this.viewportHeight) {
@@ -462,7 +450,7 @@
462450
}
463451

464452
//Reposition elements
465-
for (var i = this.particles.length - 1; i >= 0; i--) {
453+
for (i = this.particles.length - 1; i >= 0; i--) {
466454
particle = this.particles[i];
467455

468456
fixedRatioOffset = particle.isFixed ? 1 : 0;
@@ -505,7 +493,7 @@
505493
}
506494

507495
//Reposition backgrounds
508-
for (var i = this.backgrounds.length - 1; i >= 0; i--) {
496+
for (i = this.backgrounds.length - 1; i >= 0; i--) {
509497
background = this.backgrounds[i];
510498

511499
fixedRatioOffset = background.isFixed ? 0 : 1;
@@ -523,8 +511,8 @@
523511
self.viewportWidth = self.$viewportElement.width();
524512
self.viewportHeight = self.$viewportElement.height();
525513

526-
self.viewportOffsetTop = viewportOffsets !== null ? viewportOffsets.top : 0;
527-
self.viewportOffsetLeft = viewportOffsets !== null ? viewportOffsets.left : 0;
514+
self.viewportOffsetTop = viewportOffsets !== null ? viewportOffsets.top : 0;
515+
self.viewportOffsetLeft = viewportOffsets !== null ? viewportOffsets.left : 0;
528516
};
529517

530518
detect();

0 commit comments

Comments
 (0)