02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Taking the TextPlugin for a spin

In the last lecture we started working with the TextPlugin. In this lesson, I'd like to show you how to create custom animation and interactivity that is layered, giving you the full gamut of information on how to work with the TextPlugin.

Video Transcript

00:00All right, we're still with the text plugin. We're very close to finishing with it. Let's jump right in there
00:04Let's see how to create a really holistic
00:07Really cool animation just like that
00:09And obviously I encourage you to go on and create your own if you create something that's really cool really clean
00:14Really simple that would work for zero to geek. We would love to integrate it
00:18So hope to hear from you that and in the comment section suggests you go on to zero to geek right now
00:23It's relatively plaid find something there that you think would be a lot better if it was animated
00:28and come up with your solution and let us know from where we left off and it's time for us to
00:33Update our code and what I want to do is I want to wrap this copy it with the span
00:38Attribute with the span with a span because by doing that what I could do is then just focus on this one once that first
00:44Animation is complete. So let's go ahead. Let's get that sorted out. So step number one
00:49We already have access to our h2 perfect. So the next step
00:52We're just gonna wrap it with the dollar sign so we'll have access to the jQuery functions
00:56I could go ahead and just mark it as HTML and then send new HTML inside in my case
01:01I want to take that learning programming better is better and just reassign that value again and oh to
01:09switch the word programming by adding a span to it and I'll go ahead and save that and
01:19Now we're done with that. I'd saved I could go ahead and click on refresh and I'm not gonna see a difference
01:25But what I should be able to see is when I go and try to test out our learning programming
01:31better is better and by the way, look how the font grew Oto and the reason the font grows because once we did that we
01:37overrode the
01:39Wrapping that was around our text. So we're gonna have to fix that as well
01:43So if I go ahead here and I look into my editor and I look into that element here
01:48And let me just click you're the first item and I'm gonna inspect that. So what am I doing? And I'm gonna
01:55Inspect the element
01:57And we go inside to receive that we'll have you have your the span and the word programming is right in there
02:01The only thing left for us to do is go ahead and add into our H to a new class
02:06So I'm gonna go ahead enter our editor and I'll go ahead here and just go into that our target right here
02:13So if I just go ahead here, I'll just create here H to and I'll just call it that element
02:18So we don't use the same function call twice
02:21All right, so we have your H to
02:25And I'm gonna go ahead also and set my H to's class
02:28I'll add a class and I'll set the class to be that add
02:35Class and I'm gonna go ahead and set that add a class to be that expanded head. I
02:41Believe it's called add class. I might be off because I didn't memorize it. I wasn't planning on doing this
02:46We just encountered it as we were going along
02:48So I'm gonna click here refresh and hopefully well that did definitely did not work
02:53So let me go into my console and I'm just gonna play around with it until I figure it out
02:58so I'm gonna just go here and find that element very quickly and
03:05I'm just gonna go for all the H to's just so I could do this really quickly and
03:10I'm gonna go ahead and just set class maybe and
03:15Let me just put here that value that was there now if that doesn't work what I'm just gonna do
03:20Is I'm just gonna with you, you know, cuz these that stuff happen. It's gonna go ahead day query add
03:27Class and this is something that every programmer does all the time
03:31And here you go
03:31so the name of the function is add class and we could literally just jump into the
03:35Documentation really quickly and see that well, I think I wrote the right thing. Let's see if I did or I didn't I said here
03:42Add class. Yeah, that's the function. So I didn't I didn't remember it. So I didn't remember it
03:49So maybe it may be something here that I'm doing was just off a bit. But here we go
03:54So add class. I'm just gonna go ahead and try it one more time now that we have that
03:58Confirmed is I'm just gonna go ahead here to our page and let me try it one more time. I add class
04:20And let me just grab the class name from our program for a second here. It was expand head expanded head
04:27I'll go back into the browser
04:29Bring this really quickly because we're testing it out to find why wasn't it working and these stuff just happened
04:34so I'm gonna click here really quickly and
04:36That definitely did something and then we could see now if we go into that element just to see it in our inspector
04:43We'll see that all of our h2s now have the expanded head added into them
04:48Beautiful. So that is what we wanted to happen. So if we run our application one more time
04:53we'll just we just have to make sure that we're really adding that expanded class to our h2 and
05:00We'll see
05:03Let me just make sure that I don't have any typos again in case there was a typo there add class
05:11Let me just copy it sometimes, you know better safe than sorry
05:15All right, let's give it a go. Let's see if by adding the class that solves our original problem
05:24So I'm gonna click here on refresh
05:26Learning better is better. So it surely didn't but we see here that our copy is right here above again
05:32So what I'm gonna do is I'm not gonna change anything for a second
05:35I'm gonna look into this output code and see if anything major change there that we're just not capturing
05:41So first of all, we're looking at it
05:43We're seeing our copy and we can see that we have here a span and in that span we have expanded text
05:49So what we might want to do is instead of all of this craziness
05:53What if we just try to approach our class expanded text? So instead of trying to change everything, you know, let's just roll with it
06:00All right. So let's do that. I'm gonna go ahead go into my text
06:03I'm gonna go into my expanded text instead of trying to get my target only I'm gonna click here for find
06:11and we're gonna find that
06:17Expanded text that already exists
06:22we'll call a span because now it's a span and I could literally go ahead now and
06:28Trace this out to see that I'm getting that span. Let's do that first
06:31You know in these type of stuff and debugging is just a really big part of programming
06:41It just happens and you just have to deal with it
06:43Sometimes all right. So here we go. And if we look in our console
06:46We're gonna see our object and it's gonna be our object our span that we wanted to have selected
06:53Okay. So now that we got the item, you know, we don't have to go and add that span
06:58We could use that item and just continue digging deeper into it and I could go ahead and just
07:03Change its content and change its content. So the span is in that HTML area. So if I run this just one more time
07:10Let's do this and
07:12It's completely done. We won't see any visual change
07:15but if we go back into that element and literally just find it as we inspect that element we should see that now its content is
07:24split so we have here that internal span of
07:27Programming and now that I've done that I could literally go ahead and continue my animation and now say all right
07:33So let me go ahead now that I change that content again
07:36I could go ahead to my span and ask from my span the span that's inside of it
07:41so if I do here a
07:43quick console
07:45Log I could ask for my span and ask to find inside of it
07:50the span
07:52Because there's only one span inside there right now and I might need to wrap it with jQuery
07:57I don't believe I think I need to because the final automatically wrap it I believe but we'll find out in a
08:03Millisecond. So here we go. So we're getting that span that's inside of that original span. We don't have to wrap it around
08:10Beautiful. So now that we got that internal span we could go ahead and do a new tween tween to it
08:15So I literally could just go ahead and start tweening that one as well
08:19So let's do that. We're getting really close to that finale. So from item number one, I'm gonna find that item and
08:28I am gonna animate it for let's say one second and
08:32I am going to have a delay of
08:35let's say two seconds and I want to go into its text property and
08:42I'm gonna go ahead and add its values. So the first value is gonna be the value value and
08:49I'm gonna change it to
08:51JavaScript and
08:56I could I'm gonna go ahead and set a new class for it an old class for it
09:01So I'm gonna go ahead and do the same type of styling
09:04But instead of just setting the new I'm not gonna set the new class again. I'm just gonna set the old class
09:09To make sure that the old content will have that shadow. We look to it. So I'm gonna just put there that older class and
09:17Let's see. What else do we want to do? I'm gonna save this for a second and we could go in and just test it
09:23out one more time and
09:25We have your little issue here line 34. Let's go ahead and fix it line 34
09:32That means we didn't close this. So let's go ahead and close this
09:36There we go. Let's save it and
09:41We'll run it one more time. Hopefully now it's going to sort out learning
09:45Programming better is better and boom it changes to JavaScript better is better
09:50awesomeness
09:52alright, now I just want to talk about a couple quick things before we wrap things up is
09:57there's a couple more parameters that you could play around with one is a delimiter and a
10:03delimiter would basically say if you're when you're changing your copy if
10:07By default is going to break apart the copy to be every single character
10:11But if you want to you could define a different delimitator like for example every space breaking it into words
10:17So you just put here the word to live
10:20Mature and you just put here a space and now it's going to only take break it by
10:25Wherever there is a space you could put any character you want in there if there's specific characters that you want to break it
10:31With so that's it. If I save this and I run my application just one more time. It's gonna originally it's gonna
10:37Plop in not exactly the effect. I wanted it to have
10:41The next thing that I wanted to show you is this the pad space
10:45Which will basically try to hold the spacing that was there originally as the copy is changing
10:50so if I go ahead and I run it again, but let me just
10:54Comment this section out because it's really making it ugly
10:57And if I go into my secondary copy here that I switched already earlier
11:01I'm gonna add here another parameter and I'm gonna set its pad space to be true and what that's gonna do
11:08It's gonna keep my spacing. So when it's animating, it's not gonna be as jittery. So first item was a bit jittery
11:16Second item a lot less jittery, but to be honest, I don't see a major major difference between them
11:21So you'll have to play around to see which what what works best for you
11:26That's it. We're done with talking about the tween light text plugin
11:31Hope you enjoyed this lesson few last few lessons. Let's get back to working on our slideshow in the next video
11:37See you in the next lecture

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!