This course has been updated! We now recommend you take the State Machines in JavaScript with XState, v2 course.
Transcript from the "XState Actions Exercise" Lesson
[00:00:00]
>> Exercise four is going to be a simple exercise. We're going to be taking the machine that we created before, but now we wants to know what points in the box we actually put our mouse down on. So again, if you see this box once we. Oops. Once we click the box, we know that it goes from inactive to active, but we're going to be making a drag drop machine and we want to know where exactly in the box we actually clicked.
[00:00:37] So if we go to exercise four, we'll see a couple of different things. So,most of the machine is already done for you. And this is going to be very close to the same machine that you made in exercise number three. Instead of going from inactive to active, now we're going from idle to dragging.
[00:01:01] Because you could sort of envision this as something that once you put your mouse down, you're in dragging, and then once you lift your mouse up, you're no longer dragging, you're in idle. But we do wants to see what's the point on the box was clicked. So, that would be events.clientx, and events.clienty.
[00:01:26] And so in order to do this, you could do this in any way you want. But we're going to be setting the data points attribute of the box elements to display both of those points. So just to show you real quick, if this had a data points of Hello, which obviously isn't the points, it will show up over here.
[00:01:50] And so instead of Hello, we actually wants to show what point was clicked. And so the set points is going to be an action Inside this mouse down transition. So, are there any questions before we start this exercise?