MooTools – Sliders

MooTools – Sliders ”; Previous Next Slider is a functionality that reflects an action while sliding the knob or any button. You can create your own slider while defining elements, the handler, options, and call back events. Let us discuss more about slider. Creating a New Slider We first have to choose the suitable HTML elements for slider. While considering the basic idea, div elements are the most suitable for sliders because using divs, we can create child elements. We now have to set the CSS for those divs to make the div structure as a perfect slider. Here, the parent div is for slider and the child div is for knob. We now have to use these divs as sliders by passing the elements to the Slider constructor as sliderObject, and knobObject. Take a look at the following syntax for defining slider. Syntax var SliderObject = new Slider(sliderObject , knobObject , [,options,],..); We also have to define the slider options. Slider Options Let us discuss a few options that are used for sliders. Snap A snap value can be a true or false value. This determines whether the knob snaps to the steps as it is dragged along the slider. By default, it is false. Offset This is the relative offset of the knob from the starting position. Try experimenting with this one. By default, it is 0. Range This is a very useful option. You can set a range of numbers that the steps will break into. For example, if your range was [0, 200] and you had 10 steps, your steps would be 20 apart. The range can also include negative numbers, for example [-10, 0], which is very useful when inverting the scrolled. By default, it is false. Wheel Set wheel to true and the scroller will recognize the mousewheel event. When using the mousewheel, you may have to adjust the range to ensure that the mousewheel event does not appear inverted (again, more on that later). Steps The default of 100 steps is very useful as it’s easy to use as percentage. You can, however, set as many steps (that are usable) within reason. By default, it is 100. Mode Mode will define whether a slider registers itself as vertical or horizontal. However, there are a few more necessary steps to convert from horizontal and vertical. By default, it is horizontal. Callback Events There are three important callback events that a Slider provides. onChange Any change in the present step triggers the execution of the event. Check out the example given below to see when it executes. onTick Any change in the position of the handle triggers the execution of this event. Check out the example given below to see what this executes. onComplete This event executes whenever the handle is let go of. Check out the example given below to see when it executes. Example The following example explains the horizontal and vertical slider along with the event indicators. Take a look at the following code. <!DOCTYPE html> <html> <head> <style “text/css”> #slider { width: 200px; height: 20px; background-color: #0099FF; } #knob { width: 20px; height: 20px; background-color: #993333; } #sliderv { width: 20px; height: 200px; background-color: #0099FF; } #knobv { width: 20px; height: 20px; background-color: #993333; } #change{ background-color: burlywood; border: 2px solid black; width: 200px; } #complete{ background-color: burlywood; border: 2px solid black; width: 200px; } </style> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> window.addEvent(”domready”, function() { var SliderObject = new Slider(”slider”, ”knob”, { //options range: [0, 10], snap: false, steps: 10, offset: 0, wheel: true, mode: ”horizontal”, //callback events onChange: function(step){ $(”change”).highlight(”#F3F825”); $(”steps_number”).set(”html”, step); }, onTick: function(pos){ $(”tick”).highlight(”#F3F825”); $(”knob_pos”).set(”html”, pos); //this line is very necessary (left with horizontal) this.knob.setStyle(”left”, pos); }, onComplete: function(step){ $(”complete”).highlight(”#F3F825”) $(”steps_complete_number”).set(”html”, step); this.set(step); } }); var SliderObjectV = new Slider(”sliderv”, ”knobv”, { range: [-10, 0], snap: true, steps: 10, offset: 0, wheel: true, mode: ”vertical”, onChange: function(step){ $(”stepsV_number”).set(”html”, step*-1); } }); //sets the vertical one to start at 0 //without this it would start at the top SliderObjectV.set(0); //sets the slider to step 7 $(”set_knob”).addEvent(”click”, function(){ SliderObject.set(7)}); }); </script> </head> <body> <div id = “slider”> <div id = “knob”></div> </div><br/><br/> <div id = “sliderv”> <div id = “knobv”></div> </div><br/> <span id = “stepsV_number”></span> <br/> <div id = “change” class = “indicator”> <strong>onChange</strong><br/> Passes the step you are on: <span id = “steps_number”></span> </div></br/> <div id = “complete” class = “indicator”> <strong>onComplete</strong><br /> passes the current step: <span id = “steps_complete_number”></span> </div> </body> </html> Output Click on the brown knob on the horizontal or vertical sliders then drag it, you will find the step position and event indication for each action. Print Page Previous Next Advertisements ”;

MooTools – Home

MooTools Tutorial PDF Version Quick Guide Resources Job Search Discussion The full form of MooTools is My Object-Oriented Tools. It is an object-oriented, lightweight JavaScript framework. It is released under the free, open-source MIT License. It is one of the most popular JavaScript libraries. In this tutorial, we will walk through MooTools and its features. Audience This tutorial is designed for software professionals who are willing to learn MooTools (a JavaScript library) in simple and easy steps. This tutorial will give you a great understanding on various MooTools concepts. Prerequisites We assume that the reader has prior knowledge of HTML coding. It would help if the reader has had an exposure to object-oriented programming concepts and a general idea on creating online applications. Print Page Previous Next Advertisements ”;

MooTools – Periodicals

MooTools – Periodicals ”; Previous Next MooTools provides an option that supports periodicals. With this, it can call a function periodically with same level time frequency. Let us discuss the methods and features of periodicals. periodical() This method is used to raise a function periodically with the same level of time frequency. There are a few things we need to define in the beginning. One is the function which you run periodically and the second one is the numeric value that is for how often you want to raise a function (numeric value measured in milliseconds). Let us take an example that explains how a function executes in every 100 milliseconds. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var periodicalFunction = function(){ document. writeln(“www.tutorialspoint.com”); } window.addEvent(”domready”, function() { //number at the end indicates how often to fire, measure in milliseconds var periodicalFunctionVar = periodicalFunction.periodical(100); }); </script> </head> <body> </body> </html> You will receive the following output − Output Element as Second Variable The periodical function also binds a second variable which is outside the domready function(). You can bind the element as second variable into the function which you want to raise periodically. Take a look at the following syntax to understand how to pass a variable. Syntax window.addEvent(”domready”, function() { //pass something to a var var passedVar = $(”elementID”); //now periodicalFunction will be able to use “this” to refer to “passedVar” var periodicalFunctionVar = periodicalFunction.periodical(100, passedVar); }); Here passedVar is the element variable that holds an html element. And that variable passes to the periodical function periodicalFunctionVar as second variable. $Clear() $This method is used to stop the periodical function. This method helps reset the periodical variable value. Take a look at the following syntax to understand how to use $clear() function. Syntax //we clear the var that we passed the function and periodical to $clear(periodicalFunctionVar); Print Page Previous Next Advertisements ”;

MooTools – Fx.Options

MooTools – Fx.Options ”; Previous Next MooTools provides different Fx.Options which will help to Fx.Tween and Fx.Morph. These options will give you a control over the effects. Let us discuss a few options that MooTools provide. Before we proceed, take a look at the following syntax for setting up options. Syntax var morphObject = new Fx.Morph(morphElement, { //first state the name of the option //place a : //then define your option }); fps(frames per second) This option determines the number of frames per second in the animation while morphing. We can apply these fps to Morph or Tween functionalities. By default, the value of fps is 50. This means any functionality will take 50 frames per second while morphing. Example Let us take an example wherein, we will morph a div element using 5 fps. Take a look at the following code. <!DOCTYPE html> <html&gt <head> <style> #morph_element { width: 100px; height: 100px; background-color: #1A5276; border: 3px solid #dd97a1; } </style> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var morphStart = function(){ this.start({ ”width”: 200, ”height”: 200, ”background-color”: ”#d3715c” }); } window.addEvent(”domready”, function() { var morphElement = $(”morph_element”); var morphObject = new Fx.Morph(morphElement, { fps: 5 }); $(”start”).addEvent(”click”, morphStart.bind(morphObject)); }); </script> </head> <body> <div id = “morph_element”> </div><br/> <input type = “button” id = “start”value = “START”/> </body> </html> You will receive the following output − Output Click on the START button to find the morphing animation. This helps us observe the number of frames used for animation. Use different values for fps to get the difference in animation. It is recommended to use the fps value less than 10. This will help you get the difference easily. unit This option is used to set the unit type for numbers. Generally, we have three different types of units — px, %, and ems. Take a look at the following syntax. Syntax var morphObject = new Fx.Morph(morphElement, { unit: ”%” }); The above syntax is to allocate percentage to units. This means all the values in numbers are treated as percentages. link This option provides a way to manage multiple calls to start an animation. If you apply multiple event calls at a time, these calls will be taken in as link calls. Once the first call finishes, then the second call executes automatically. It contains the following three options − ignore − This is the default option. It ignores any number of calls until it completes the effect. cancel − This cancels the current effect, when there is another being made. It follows the newest call precedence. Chain − This lets you chain the effects together and maintain the stack of calls. It executes all the calls until it goes through all the chained calls in the stack. Take a look at the following syntax for using the link option. Syntax var morphObject = new Fx.Morph(morphElement, { link: ”chain” }); Duration This option is used to define the duration of the animation. For example, if you want an object to move 100px in the duration of 1 second, then it will go slower than an object moving 1000px in 1 second. You can input a number which is measured in milliseconds. Or you can use any of these three options in place of numbers. Short = 250ms Normal = 500ms (default) Long = 1000ms Take a look at the following syntax for using duration. Syntax var morphObject = new Fx.Morph(morphElement, { duration: ”long” }); Or, var morphObject = new Fx.Morph(morphElement, { duration: 1000 }); transition This option is used to determine the transition type. For example, if it should be a smooth transition or should it start out slowly then speed up towards the end. Take a look at the following syntax to apply transition. Syntax var tweenObject = new Fx.Tween(tweenElement, { transition: ”quad:in” }); The following table describes the different types of transitions. S.No. Transition type & Description 1 Linear Displays a linear transition with in, out, in-out events 2 Quad Displays a quadratic transition with in, out, in-out events 3 Cubic Displays a cubicular transition with in, out, in-out events 4 Quart Displays a quartetic transition with in, out, in-out events 5 Quint Displays a quintic transition with in, out, in-out events 6 Pow Used to generate Quad, Cubic, Quart and Quint with in, out, in-out events 7 Expo Displays an exponential transition with in, out, in-out events 8 Circ Displays a circular transition with in, out, in-out events 9 Sine Displays a sineousidal transition with in, out, in-out events 10 Back Makes the transition go back, then all forth with in, out, in-out events 11 Bounce Makes the transition bouncy with in, out, in-out events 12 Elastic Elastic curve transition with in, out, in-out events Print Page Previous Next Advertisements ”;

MooTools – Fx.Events

MooTools – Fx.Events ”; Previous Next Fx.Events provides some options to raise some codes at different levels throughout the animation effect. It provides you the control over your tweens and morphs. The option that Fx.Events provides − onStart − It will raise the code to execute when the Fx starts. onCancel − It will raise the code to execute when the Fx is cancelled. onComplete − It will raise the code to execute when the Fx is completed. onChainComplete − will raise the code to execute when the chained Fx completes. Example Let us take an example wherein, there are divs on the web page. We proceed by applying Event methods to the divs. The first method is the onStart() method to highlight the div when mouse pointer enters into the div area. The second one is the onComplete() method which highlights the div when mouse pointer leaves the div area. And when the mouse pointer enters into the div area automatically the div size increases by 400px. We will try to execute all these functionalities using the Fx.Events methods. Take a look at the following code. <!DOCTYPE html> <html> <head> <style> #quadin { width: 100px; height: 20px; background-color: #F4D03F; border: 2px solid #808B96; } #quadout { width: 100px; height: 20px; background-color: #F4D03F; border: 2px solid #808B96; } #quadinout { width: 100px; height: 20px; background-color: #F4D03F; border: 2px solid #808B96; } </style> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var enterFunction = function() { this.start(”width”, ”400px”); } var leaveFunction = function() { this.start(”width”, ”200px”); } window.addEvent(”domready”, function() { var quadIn = $(”quadin”); var quadOut = $(”quadout”); var quadInOut = $(”quadinout”); quadIn = new Fx.Tween(quadIn, { link: ”cancel”, transition: Fx.Transitions.Quad.easeIn, onStart: function(passes_tween_element){ passes_tween_element.highlight(”#C54641”); }, onComplete: function(passes_tween_element){ passes_tween_element.highlight(”#E67F0E”); } }); quadOut = new Fx.Tween(quadOut, { link: ”cancel”, transition: ”quad:out” }); quadInOut = new Fx.Tween(quadInOut, { link: ”cancel”, transition: ”quad:in:out” }); $(”quadin”).addEvents({ ”mouseenter”: enterFunction.bind(quadIn), ”mouseleave”: leaveFunction.bind(quadIn) }); $(”quadout”).addEvents({ ”mouseenter”: enterFunction.bind(quadOut), ”mouseleave”: leaveFunction.bind(quadOut) }); $(”quadinout”).addEvents({ ”mouseenter”: enterFunction.bind(quadInOut), ”mouseleave”: leaveFunction.bind(quadInOut) }); }); </script> </head> <body> <div id = “quadin”> Quad : in</div><br/> <div id = “quadout”> Quad : out</div><br/> <div id = “quadinout”> Quad : in-out</div><br/> </body> </html> You will receive the following output − Output Print Page Previous Next Advertisements ”;

MooTools – Input Filtering

MooTools – Input Filtering ”; Previous Next MooTools can filter the user input and it can easily recognize the type of input. The basic input types are Number and String. Number Functions Let us discuss a few methods that will check if an input value is a number or not. These methods will also help you manipulate the number input. toInt() This method converts any input value to the integer. You can call it on a variable and it will try to give the regular integer from whatever the variable contains. Let us take an example that design a web page that contain a textbox and a button named TO INT. The button will check and return the value that you entered into the textbox as real integer. If the value is not an integer, then it will return the NaN symbol. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var toIntDemo = function(){ var input = $(”input”).get(”value”); var number = input.toInt(); alert (”Value is : ” + number); } window.addEvent(”domready”, function() { $(”toint”).addEvent(”click”, toIntDemo); }); </script> </head> <body> Enter some value: <input type = “text” id = “input” /> <input type = “button” id = “toint” value = “TO INT”/> </body> </html> You will receive the following output − Output Try different values and convert them into real integers. typeOf() This method examines the value of a variable you pass and, it returns the type of that value. Let us take an example wherein, we design a webpage and check if the input value is Number, String or Boolean. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var checkType = function(){ var input = $(”input”).get(”value”); var int_input = input.toInt(); if(typeOf(int_input) != ”number”){ if(input == ”false” || input == ”true”){ alert(“Variable type is : Boolean”+” – and value is: “+input); } else{ alert(“Variable type is : “+typeof(input)+” – and value is: “+input); } } else{ alert(“Variable type is : “+typeof(int_input)+” – and value is:”+int_input); } } window.addEvent(”domready”, function() { $(”checktype”).addEvent(”click”, checkType); }); </script> </head> <body> Enter some value: <input type = “text” id = “input” /> <input type = “button” id = “checktype” value = “CHECK TYPE”/> </body> </html> You will receive the following output − Output Try the different values and check the type. limit() The limit() method is used to set the lower bound and upper bound values for a particular number. The number should not exceed the upper bound value. If it exceeds, then the number is changed to the upper bound value. This process is same with the lower bound also. Let us take an example that provides a text box for entering a value, provide a button to check the limit of that value. The default limit that we used in the example is 0 to 255. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var checkLimit = function(){ var input = $(”input”).get(”value”); var number = input.toInt(); var limited_number = number.limit(0, 255); alert(“Number is : ” + limited_number); } window.addEvent(”domready”, function() { $(”check_limit”).addEvent(”click”, checkLimit); }); </script> </head> <body> Enter some value: <input type = “text” id = “input” /> <input type = “button” id = “check_limit” value = “Check Limit (0 to 255)”/> </body> </html> You will receive the following output − Output Try different numbers to check the limit. rgbToHex() The rgbToHex() method is to convert from the red, green, and blue values to the Hexadecimal value. This function deals with numbers and belongs to the Array collection. Let us take an example wherein, we will design a web page to enter the individual values for Red, Green, and Blue. Provide a button to convert all three into hexadecimal values. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var rgbToHexa_Demo = function(){ var red = $(”red”).get(”value”); var red_value = red.toInt(); var green = $(”green”).get(”value”); var green_value = green.toInt(); var blue = $(”blue”).get(”value”); var blue_value = blue.toInt(); var color = [red_value, green_value, blue_value].rgbToHex(); alert(” Hexa color is : ” + color); } window.addEvent(”domready”, function() { $(”rgbtohex”).addEvent(”click”, rgbToHexa_Demo); }); </script> </head> <body> Red Value: <input type = “text” id = “red” /><br/><br/> Green Value: <input type = “text” id = “green” /><br/><br/> Blue Value: <input type = “text” id = “blue” /><br/><br/> <input type = “button” id = “rgbtohex” value = “RGB To HEX”/> </body> </html> You will receive the following output − Output Try different Red, Green, and Blue values and find the hexadecimal values. String Functions Let us discuss a few methods of String class which can manipulate the input String value. Before we proceed, let us take a look at the following syntax of how to call a string function. String var my_variable = “Heres some text”; var result_of_function = my_variable.someStringFunction(); Or, var result_of_function = “Heres some text”.someStringFunction(); trim() This method is used to remove the whitespace of the front position and the end position of a given string. It does not touch any white spaces inside the string. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> window.addEvent(”domready”, function() { var input_str = ” This is tutorialspoint.com “; document.writeln(“<pre>Before trim String is : |-“+input_str+”-|</pre>”); var trim_string = input_str.trim(); document.writeln(“<pre>After trim String is : |-“+trim_string+”-|</pre>”); }); </script> </head> <body> </body> </html> You will receive the following output − Output In the above alert boxes, you can find the differences in String before calling trim() method and after calling trim() method.

MooTools – Style Properties

MooTools – Style Properties ”; Previous Next MooTools provides some Special methods to set and get style property values for DOM elements. We use different style properties such as width, height, background color, font weight, font color, border, etc. By setting and getting different values to these style properties, we can present HTML elements in different styles. Set and Get Style Properties MooTools library contains different methods which are used to set or get the value of a particular style property or multiple style properties. setStyle() This method allows you to set the value for a single property of DOM element. This method will work on the selector object of a particular DOM element. Let us take an example that provides background color for div element. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> window.addEvent(”domready”, function() { $(”body_wrap”).setStyle(”background-color”, ”#6B8E23”); $$(”.class_name”).setStyle(”background-color”, ”#FAEBD7”); }); </script> </head> <body> <div id = “body_wrap”>A</div> <div class = “class_name”>B</div> <div class = “class_name”>C</div> <div class = “class_name”>D</div> <div class = “class_name”>E</div> </body> </html> You will receive the following output − Output getStyle() getStyle() method is to retrieve the value of a style property of an element. Let us take an example that retrieves the background-color of a div named body_wrap. Take a look at the following syntax. Syntax //first, set up your variable to hold the style value var styleValue = $(”body_wrap”).getStyle(”background-color”); Multiple Style Properties MooTools library contains different methods used to set or get the value of a particular style property or multiple style properties. setStyle() If you want to set multiple style properties on a single element or an array of elements then you have to use the setStyle() method. Take a look at the following syntax of the setStyle() method. Syntax $(”<element-id>”).setStyles({ //use different style properties such as width, height, background-color, etc. }); Example <!DOCTYPE html> <html> <head> <style> #body_div { width: 200px; height: 200px; background-color: #eeeeee; border: 3px solid #dd97a1; } </style> <script type = “text/javascript” src = “MooTools-Core-1.6.0.js”></script> <script type = “text/javascript” src = “MooTools-More-1.6.0.js”></script> <script type = “text/javascript”> var setWidth = function(){ $(”body_div”).setStyles({ ”width”: 100 }); } var setHeight = function(){ $(”body_div”).setStyles({ ”height”: 100 }); } var reset = function(){ $(”body_div”).setStyles({ ”width”: 200, ”height”: 200 }); } window.addEvent(”domready”, function() { $(”set_width”).addEvent(”click”, setWidth); $(”set_height”).addEvent(”click”, setHeight); $(”reset”).addEvent(”click”, reset); }); </script> </head> <body> <div id = “body_div”> </div><br/> <input type = “button” id = “set_width” value = “Set Width to 100 px”/> <input type = “button” id = “set_height” value = “Set Height to 100 px”/> <input type = “button” id = “reset” value = “Reset”/> </body> </html> You will receive the following output − Output Try these buttons on the web page, you can see the difference with the div size. Print Page Previous Next Advertisements ”;

MooTools – Drag and Drop

MooTools – Drag and Drop ”; Previous Next MooTools provides a tremendous feature that helps you add drag and drop drag functionalities to your web page elements. We can do this by creating our own new Drag.Move object. Using this object, you can define your options and events. Drag and Drag.Move classes are from the MooTools More library. Let us discuss the options and events of Drag.Move object. Drag.Move Drag.Move is an Object used to add Drag and Drop feature to the html elements. Drag.Move extends Drag, so we can use all the Options and Events of Drag class by Drag.Move object. Take a look at the following syntax and understand how to use Drag.Move object. Syntax var myDrag = new Drag.Move(dragElement, { // Drag.Move Options droppables: dropElement, container: dragContainer, // Drag Options handle: dragHandle, // Drag.Move Events // the Drag.Move events pass the dragged element, // and the dropped into droppable element onDrop: function(el, dr) { //will alert the id of the dropped into droppable element alert(dr.get(”id”)); }, // Drag Events // Drag events pass the dragged element onComplete: function(el) { alert(el.get(”id”)); } }); Drag.Move Options Drag.Move provides the following options to maintain html elements with Drag and Drop features − droppable − This helps you set the selector of droppable elements (the elements that register on drop-related events). container − This helps you set the drag element’s container (keeps the element inside). snap − This helps you set how many px the user must drag the cursor before the draggable element starts dragging. The default is 6, and you can set it to any number of variable representing a number. handle − This helps you add a handle to your draggable element. Handle becomes the only element that will accept the grab. Take a look at the following syntax for how and where to define the droppable and container, snap, and handle elements. Syntax //here we define a single element by id var dragElement = $(”drag_element”); //here we define an array of elements by class var dropElements = $$(”.drag_element”); var dragContainer = $(”drag_container”); var dragHandle = $(”drag_handle”); //now we set up our Drag.Move object var myDrag = new Drag.Move(dragElement , { // Drag.Move Options // set up our droppables element with the droppables var we defined above droppables: dropElements , // set up our container element with the container element var container: dragContainer // set up pixels the user must drag. Snap: 10 // Adds a handle to your draggable element handle: dragHandle }); Drag.Move events Drag.Move events provide different functions that can be used in different levels of the action. For example, when you start to drag or drop an object, each Drag.Move event will pass the dragged element or the dropped element as parameters. The following are the supported events − onStart() This raises an event on the start of drag. If you set a long snap, then this event would not raise until the mouse is at a distance. Take a look at the following syntax. Syntax var myDrag = new Drag.Move(dragElement , { // Drag options will pass the dragged element as a parameter onStart: function(el) { // put whatever you want to happen on start in here } }); onDrag() This raises an event continuously while you are dragging an element. Take a look at the following syntax. Syntax var myDrag = new Drag.Move(dragElement , { // Drag options will pass the dragged element as a parameter onDrag: function(el) { // put whatever you want to happen on drag in here } }); onDrop() This raises an event when you drop the draggable element into a droppable element. Take a look at the following syntax. Syntax var myDrag = new Drag.Move(dragElement , { // It will pass the draggable element (”el” in this case) // and the droppable element the draggable is interacting with (”dr” here) onDrop: function(el, dr) { // put whatever you want to happen on drop in here } }); onLeave() This raises an event when a draggable element leaves a droppable element’s bounds. Take a look at the following syntax. Syntax var myDrag = new Drag.Move(dragElement , { // It will pass the draggable element (”el” in this case) // and the droppable element the draggable is interacting with (”dr” here) onLeave: function(el, dr) { // put whatever you want to happen on Leave from droppable area in here } }); onEnter() This raises when a draggable element enters a droppable element area. Take a look at the following syntax. Syntax var myDrag = new Drag.Move(dragElement , { // It will pass the draggable element (”el” in this case) // and the droppable element the draggable is interacting with (”dr” here) onEnter: function(el, dr) { // this will fire when a draggable enters a droppable element } }); onComplete() This raises an event. onComplete refers to when you drop a droppable, and it will raise whether or not you land in a droppable. Take a look at the following syntax. Syntax var myDrag = new Drag.Move(dragElement , { // Drag Options // Drag options will pass the dragged element as a parameter onComplete: function(el) { // put whatever you want to happen on complete } }); Let us take an example that will explore all the features explained in this chapter. The features are — Drag, Drag.Move, onEnter, onLeave, onDrop, onStart, onDrag, and onComplete. In this example, we are providing one HANDLE, using that you can drag the draggable object anywhere into the container. For every action, there is a notification on the left side (indicated in blue color). There is a Droppable area in the container. If the Draggable object enters into the Droppable area, then the last three indicators are activated. Take a look at the following code. Example <!DOCTYPE html> <html> <head> <style> /* this is generally a good idea */ body { margin: 0; padding: 0; } /* make sure the draggable element has “position: absolute” and then top and left