File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
JavaScript3/Week9/classwork/buggy-object/solution Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ var pageSize = document.documentElement.clientWidth;
4
4
var obj = {
5
5
div : document . querySelector ( 'div' ) ,
6
6
isMoving : false , // is currently moving
7
- // EDIT : normal function
7
+ // EDIT : normal function instead of arrow function. Here the this object will point to obj.
8
8
move : function ( ) {
9
- // EDIT : should use offsetWidth since style object oly contains inline css
9
+ // EDIT : should use offsetWidth since style object only contains inline css
10
10
this . div . style . transform = "translateX(" + ( pageSize - this . div . offsetWidth ) + "px)" ;
11
11
this . isMoving = true ;
12
- // EDIT : using arrow function as callback if we want the this in the function to point to obj
12
+ // EDIT : using arrow function as callback if we want the this in the function to point to obj. Otherwise this will point to this.div
13
13
this . div . addEventListener ( 'transitionend' , ( ) => {
14
14
this . isMoving = false ;
15
15
} )
You can’t perform that action at this time.
0 commit comments