Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc11859

Browse files
senner008benna100
authored andcommitted
comments
1 parent fef49f0 commit dc11859

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

JavaScript3/Week9/classwork/buggy-object/solution/transition.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ var pageSize = document.documentElement.clientWidth;
44
var obj = {
55
div : document.querySelector('div'),
66
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.
88
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
1010
this.div.style.transform = "translateX(" + (pageSize - this.div.offsetWidth) + "px)";
1111
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
1313
this.div.addEventListener('transitionend', () => {
1414
this.isMoving = false;
1515
})

0 commit comments

Comments
 (0)