1 00:00:00,600 --> 00:00:06,290 Hello and welcome to this chick query video on corbat functions. 2 00:00:06,350 --> 00:00:13,700 But volunteers are used to prevent kord executing too early. 3 00:00:13,710 --> 00:00:19,220 They are usually used with animations or that you query effects. 4 00:00:19,290 --> 00:00:27,360 So what the call above about function does it holds back the next line of code from executing on till 5 00:00:27,690 --> 00:00:33,100 the current effect or animation is completely finished. 6 00:00:33,540 --> 00:00:37,630 If they call about function is not included in the code. 7 00:00:37,830 --> 00:00:42,810 It may cause the next line of code to execute. 8 00:00:43,110 --> 00:00:50,880 Pretty much surely before the animation or effect has completed this can sometimes create errors in 9 00:00:50,880 --> 00:00:57,290 the application or could swear by a corbat function is specified. 10 00:00:57,360 --> 00:01:04,720 It will only execute after the corette effect or animation is completed. 11 00:01:05,310 --> 00:01:10,290 I have called my editor of course some piece of code here. 12 00:01:10,500 --> 00:01:16,470 So in between the script tag I have caught some Gick query function. 13 00:01:16,690 --> 00:01:20,000 So the there's line near Line 6. 14 00:01:20,160 --> 00:01:26,170 We've got the documents already function which gets the document ready. 15 00:01:26,250 --> 00:01:32,350 Make sure the page is ready fully could execute and then onli sermon. 16 00:01:32,370 --> 00:01:36,880 We've got the button as a selector. 17 00:01:36,930 --> 00:01:40,590 There is a button here saw when the button is clear. 18 00:01:40,590 --> 00:01:49,990 Tom I have a tidy click handler to the button so when the button is clicked it will fire up an action. 19 00:01:49,990 --> 00:01:55,790 The action that will call will call on another selector which is the diff. 20 00:01:55,820 --> 00:02:05,160 Deep here so any button is click the div wall height and add it all high because I specified a taut 21 00:02:05,160 --> 00:02:08,480 height event here I am. 22 00:02:08,500 --> 00:02:09,810 So don't hide look. 23 00:02:09,840 --> 00:02:13,080 Hide the Deve when the botanist clicked on. 24 00:02:13,080 --> 00:02:19,580 Also inside the hide function I have specified a parameter. 25 00:02:19,950 --> 00:02:22,310 The first time it passed it is slow. 26 00:02:22,320 --> 00:02:29,490 I wanted to hide the button do slowly have also included functions with this function. 27 00:02:29,490 --> 00:02:33,000 Here is acting as a core function. 28 00:02:33,030 --> 00:02:37,940 It will only run when the mission is completed. 29 00:02:38,310 --> 00:02:40,920 So this this is the core by this function. 30 00:02:40,920 --> 00:02:48,030 So when the only measures completed is function here we run this line of code here which is a lot and 31 00:02:48,060 --> 00:02:54,730 he will display this message board without the call back form included here. 32 00:02:55,020 --> 00:03:05,460 Apparently be an emission may be slow to hide the box and may cause this alert to execute prematurely. 33 00:03:05,490 --> 00:03:11,550 If this function corbucci function is not specified So let's check this out. 34 00:03:12,000 --> 00:03:17,980 So this is my nice red button and this is my DVR which is a blue box. 35 00:03:18,150 --> 00:03:24,820 So if I click on this button here the div will vanish. 36 00:03:24,840 --> 00:03:26,270 That's what I specified here. 37 00:03:26,280 --> 00:03:38,060 Women don't hide from methot and I've told it to hide it slowly and this function is cool but fine John 38 00:03:38,060 --> 00:03:42,720 will hold back this good from running on until that is finished. 39 00:03:42,720 --> 00:03:44,550 So let's do that. 40 00:03:45,090 --> 00:03:47,840 He is gone now that is gone. 41 00:03:47,850 --> 00:03:52,430 The next line of code has now executed with this alert box. 42 00:03:52,540 --> 00:03:53,360 All right. 43 00:03:53,430 --> 00:03:58,610 So next if I remove the core function you see what I saw. 44 00:03:58,620 --> 00:04:05,340 I have now removed the corbat function from this power here. 45 00:04:05,520 --> 00:04:07,520 So all is got to move past it. 46 00:04:07,660 --> 00:04:12,800 Apparently there of 1000 milliseconds that means it will be slow. 47 00:04:12,900 --> 00:04:13,840 In hiding. 48 00:04:13,890 --> 00:04:14,490 Div. 49 00:04:14,760 --> 00:04:21,470 So in that time he doesn't allow this piece of code here executes before the action. 50 00:04:21,510 --> 00:04:26,810 The animation is completed so what taps are let me click on this click on this. 51 00:04:26,970 --> 00:04:34,200 I will expect this alert to execute before the animation completes because the animation is slow to 52 00:04:34,200 --> 00:04:36,930 hide so that 5 53 00:04:40,210 --> 00:04:45,730 me refresh that O K has some slight issues. 54 00:04:45,820 --> 00:04:48,490 He could be left out. 55 00:04:49,710 --> 00:04:53,400 This cut one of these semicolons. 56 00:04:53,490 --> 00:04:59,490 Anyway this is the code I have removed the core function from this. 57 00:04:59,550 --> 00:05:01,930 Parameters have passed. 58 00:05:02,130 --> 00:05:05,870 A tiny parameters of 1000 milliseconds. 59 00:05:05,910 --> 00:05:15,750 So if I execute this code because I've removed the core function this line of code here may will not 60 00:05:15,750 --> 00:05:18,720 wait for the animation to complete. 61 00:05:18,720 --> 00:05:25,410 Don't forget because we've just group a query called this execute line after line. 62 00:05:25,650 --> 00:05:31,720 So but because the animation value I've set it will make it slow to hide. 63 00:05:31,830 --> 00:05:35,130 The alert will not wait and just execute. 64 00:05:35,130 --> 00:05:40,470 So this is what can cause problems in the life code. 65 00:05:40,470 --> 00:05:51,400 So if I run that see this has a code before any mission completed. 66 00:05:51,630 --> 00:05:54,570 He didn't wait for the animation to complete. 67 00:05:54,630 --> 00:06:04,140 So this is why it is important to use a call-back function when inside the animation values in this 68 00:06:04,140 --> 00:06:04,790 video. 69 00:06:04,830 --> 00:06:08,920 I explained what he calls back function. 70 00:06:08,970 --> 00:06:14,150 It's the importance of fake corbat function. 71 00:06:14,220 --> 00:06:20,100 It helps prevent code from executing too early. 72 00:06:20,100 --> 00:06:25,890 This is especially use with Jake Query effects like animation. 73 00:06:26,040 --> 00:06:36,570 So I showed an example whereby I remove the corbat function and record execute executed too early because 74 00:06:36,630 --> 00:06:46,140 it did not wait for the animation to complete whereby I included the core function inside the parameters 75 00:06:46,650 --> 00:06:48,490 of the animations. 76 00:06:48,500 --> 00:06:56,340 Well this is the height and motion and between parentheses includes two parameters one is for the high 77 00:06:56,370 --> 00:07:06,600 to be slow and the other days for a function and the function and here he will not run on till the animation 78 00:07:06,930 --> 00:07:09,520 or the div is completely hit. 79 00:07:09,720 --> 00:07:11,980 So let's test this one one time. 80 00:07:12,360 --> 00:07:14,790 Click on that you see and then run. 81 00:07:14,820 --> 00:07:16,670 This is how it's meant to work. 82 00:07:16,830 --> 00:07:23,550 This the next line of code should only execute after Lisa's completeness is completed a devious hida 83 00:07:24,060 --> 00:07:27,030 but with without the core but function. 84 00:07:27,030 --> 00:07:35,500 This piece of code you execute to see if the parameter past is too slow in hiding the div. 85 00:07:35,790 --> 00:07:36,850 Thank you so much. 86 00:07:36,870 --> 00:07:41,760 I all the information in this video has been helpful. 87 00:07:41,760 --> 00:07:46,980 You now have an idea of why a call but function is used. 88 00:07:47,160 --> 00:07:48,940 Thank you and bye for now.