Skip to content

Commit d6c62ba

Browse files
committed
fix(main.js):add back basicLeft in document.addEventListener per reviewer #2 and cameronwp#3
1 parent 5909896 commit d6c62ba

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

views/js/main.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
/*
22
Welcome to the 60fps project! Your goal is to make Cam's Pizzeria website run
33
jank-free at 60 frames per second.
4-
54
There are two major issues in this code that lead to sub-60fps performance. Can
65
you spot and fix both?
7-
8-
96
Built into the code, you'll find a few instances of the User Timing API
107
(window.performance), which will be console.log()ing frame rate data into the
118
browser console. To learn more about User Timing API, check out:
129
http://www.html5rocks.com/en/tutorials/webperformance/usertiming/
13-
1410
Creator:
1511
Cameron Pittman, Udacity Course Developer
1612
cameron *at* udacity *dot* com
@@ -492,7 +488,7 @@ function updatePositions() {
492488
var items = document.getElementsByClassName('mover');//? where is .mover defined? ln 529
493489
var phaseBase=document.body.scrollTop / 1250;
494490
for (var i = 0; i < items.length; i++) {
495-
var phase =Math.sin(phaseBase + (i % 8)) * 100+"px";
491+
var phase =Math.sin(phaseBase + (i % 8)) * 200+"px";
496492
items[i].style.transform="translate3d("+phase+",0,0)";//used to be items[i].style.left = ...
497493
}
498494

@@ -517,13 +513,15 @@ document.addEventListener('DOMContentLoaded', function() {
517513
var colNum = 8;
518514
var rowNum=5;
519515
var rowHeight=Math.floor(window.innerHeight/rowNum);
516+
var colWidth = Math.floor(window.innerWidth/colNum);
520517
var pizzaNum = colNum*rowNum;
521518
var movingPizzas=document.getElementById("movingPizzas1");
522519
for (var i = 0; i < pizzaNum; i++) {
523520
var elem = document.createElement('img');
524521
elem.className = 'mover';
525522
elem.src = "images/pizza.png";
526523
elem.style.top = (Math.floor(i / colNum) * rowHeight) + 'px';
524+
elem.basicLeft = (i % colNum) * colWidth;
527525
movingPizzas.appendChild(elem);
528526
}
529-
});
527+
});

0 commit comments

Comments
 (0)