INTRODUCTION TO HTML5 Drag and Drop in HTML5. Browsers Support  Currently, most of the major HTML5 desktop web browsers support the new HTML5 drag-and-drop.

Slides:



Advertisements
Similar presentations
3.02D HTML Overview 3.02 Develop webpages.
Advertisements

Interaction Design: Visio
Integration between HTML 5 Drag & Drop and SAP ABAP HTTP ICF Services Alessandro Spadoni & Patrizia Rossi October 8th,
23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
1 Lesson 5 Introduction to Cascading Style Sheets HTML and JavaScript BASICS, 4 th Edition Barksdale / Turner.
The Web Warrior Guide to Web Design Technologies
Ch. 6 Web Page Design – Absolute Positioning, Image Maps, and Navigation Bars Mr. Ursone.
© by Pearson Education, Inc. All Rights Reserved.
Tutorial 15 Working with the Event Model. XP Objectives Compare the IE and W3C event models Study how events propagate under both event models Write a.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Computer Science 103 Chapter 4 Advanced JavaScript.
My Workspace Profile. Using the course menu, click on Profile.
XP Tutorial 8 New Perspectives on JavaScript, Comprehensive1 Working with the Event Model Creating a Drag-and-Drop Shopping Cart.
 jQuery Mobile An Introduction. What is jQuery Mobile  A framework built on top of jQuery, used for creating mobile web applications  Designed to make.
Canvas, SVG, Workers Doncho Minkov Telerik Corporation
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
CST JavaScript Validating Form Data with JavaScript.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
IE 411/511: Visual Programming for Industrial Applications
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Web Design Fundamentals Demystifying Basic HTML. 2 After completing this lesson, you will be able to: Understand the basics of HTML coding. Use HTML tags.
Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and attributes Create.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Word 2010 Vocabulary List 1. Click and Type - A feature that allows you to double-click a blank area of a document to position the cursor in that location,
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Using Client-Side Scripts to Enhance Web Applications 1.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
XHTML1 Images N100 Building a Simple Web Page. XHTML2 The Element The src attribute specifies the filename of an image file To include the src attribute.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Lesson 11: Looking at Files and Folders what a file or folder is on the computer how to recognize a file or folder on the desktop how to recognize the.
JavaScript - A Web Script Language Fred Durao
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Lesson 2: Manipulating Text Courseware #: 3240
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
1 Lesson 11 Exploring Microsoft Office 2010 Computer Literacy BASICS: A Comprehensive Guide to IC 3, 4 th Edition Morrison / Wells.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Basics of Windows 95/98/NT. Versions of Windows Windows 95 and 98 used mainly on standalone computers Windows NT used on networked computers (as in our.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
USING JAVASCRIPT TO SHOW AN ALERT Web Design Sec 6-2 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
Project 5: Using Pop-Up Windows Essentials for Design JavaScript Level One Michael Brooks.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Easy WP Guide V2.6 for WordPress 3.8. easywpguide.com Adding Tags within your Post Adding Tags whilst editing your Post, will automatically assign those.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
JavaScript, Sixth Edition
Chapter 5 Validating Form Data with JavaScript
Setting up Categories, Grading Preferences and Entering Grades
Introduction to JavaScript Events
Multi-host Internet Access Portal (MIAP) Enhancement Guide
WEB PROGRAMMING JavaScript.
Working with the Event Model
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
Drag-and-Drop Processing
Web Development Using ASP .NET
Using Templates and Library Items
JavaScript.
Presentation transcript:

INTRODUCTION TO HTML5 Drag and Drop in HTML5

Browsers Support  Currently, most of the major HTML5 desktop web browsers support the new HTML5 drag-and-drop attributes and events, except for Opera  HTML5 native drag-and-drop is nonexistent in today’s HTML5- aware mobile web browsers.

Identify Draggable Elements  Elements that you intend to be clicked and dragged must be identified as draggable, using the draggable attribute.  When this is set, HTML5 web browsers will fire off additional browser events that you can use in JavaScript to follow the drag-and-drop process.  This attribute causes no visual change to the element; that must be handled by CSS.  For example, you can indicate to the user that an element is draggable by changing the mouse cursor displayed over the element:

Identify Drop Zone Elements  There are two ways to identify elements as a drop zone, or in other words, accept draggable elements.  Note that the first method is recommended, as it is supported by the most web browsers.

The dragenter, dragover, and dragleave Event Methods  The first and primary method involves simply assigning drop- point elements a specific class name, such as dropzone, and then using that class name in JavaScript to register listener functions for your drag-and-drop events.

The dropzone Attribute Method  The alternative method involves using the new dropzone attribute.  None of the major web browsers support this attribute, but once implemented, it will allow you to simplify the dragenter, dragover, and dragleave events.

The dropzone Attribute Method  The feedback parameter can be copy, move, or link and sets the mouse icon effect.  Only one feedback value can be specified, but if unspecified, it defaults to copy.  The kind parameter is a single character that states the acceptable data type.  Use f for accepting files dragged from the desktop and s for accepting data strings.  type is the MIME type of the data accepted. Multiple kind:type parameters can be specified, if required.

The dropzone Attribute Method  For example, if you were copying image files dragged from the desktop, the dropzone attribute would be  If you were moving a data string, use

Dragstart Event  The dragstart event occurs on the element that has the draggable=’true’ attribute set.  When you register this event listener on a draggable element, you will be notified when the user has clicked down and initiated the drag-and-drop process.  Your registered dragstart event function can be used to fade out the draggable element object, to use event.dataTransfer.setData() to store supplementary information in the dragged item, and to assign a drag image under the mouse cursor.

Drag Event  The drag event occurs on the element that has the draggable=’true’ attribute set.  When you register this event listener on a draggable element, you will be persistently notified while the user is actively dragging something.  This event is not commonly used but can be if you need to know exactly where the draggable element is on the web page, as it is being dragged.

Dragenter Event  The dragenter event fires for every element the mouse drag enters across the web page.  Most web page elements you will not be interested in, so you can isolate your dragenter activity by registering an event listener only on drop zone elements.  Your registered dragenter event function can be used to highlight a drop zone element area, which provides a visual cue to the user that the element being dragged can be dropped here.

Dragover Event  The dragover event is very similar to drag and dragenter, except that this event fires continuously only while the user drags and hovers over a drop zone element on the web page.  The purpose of this event is to set the drop effect for the user feedback as the user actually moves the mouse.

Dragleave Event  The dragleave event is also very similar to dragenter, except it fires for every element that the mouse drag leaves across the web page.  Again, most elements will be uninteresting, except for those that you have already registered as dragenter and dragover event listeners.  Your registered dragleave event function can be used to remove the dragenter highlight on a drop zone element area.

Drop Event  The drop event occurs on the drop zone element where the user releases the mouse button.  This allows you to identify where exactly the user completed the drag-and-drop process and to launch the appropriate JavaScript code to process the user’s action.  Your registered drop event function can be used to verify that a drop action was appropriate, such as if the dragged element is compatible with the dropped element.

Dragend Event  The dragend event occurs after the user releases the mouse button.  This differs from the drop event as dragend fires from the draggable element, not the drop zone element.  In other words, dragend occurs regardless of whether the drag-and-drop process completed successfully or not.  Your registered dragend event function can be used to undo what the dragstart function did.  For example, if dragstart faded out the draggable element object, dragend should restore it.

Dragging Objects out of a Web Page  Only the dragstart and dragend events fire when the drag- and-drop process begins and finishes. All other events are omitted because the drop point is outside of the web browser.  The information you store in event.dataTransfer.setData() will then be transferred to your operating system.  It is then up to the desktop or application to interpret that data correctly.

Dragging Objects into a Web Page  Only the dragenter, dragover, dragleave, and drop events fire when dragging something from your desktop into your web page.  All other events are omitted because the drag start point is outside of the web browser.  The information being brought into your web page can be read using event.dataTransfer.getData(), which is usually a path to the local file.

Specify Objects to Drag

 Apply CSS

Specify Objects to Drag

Specify a Drop Zone

 Apply CSS to the dropzone class

Specify a Drop Zone

Handle the Drag-and-Drop Events

 After processing the dragstart event, you need to instruct the browser how to handle the data as it is being dragged across the screen.  First, cancel the default event using event.preventDefault() and by returning false; second, specify the appropriate drop effect that will actually be displayed to the user:

Handle the Drag-and-Drop Events  The event.preventDefault() and return false commands both serve the same purpose but apply to different browsers, yet this code is safe to define on all browsers.  Preventing the default action purpose is to instruct the browser that this individual function is providing all the functionality for this particular event and that it should therefore avoid the default event actions built into the browser itself.  In the case of the dragover event, the default actions all relate to the built-in drag-and-drop functionality in the browser’s own user interface, such as dragging links into either the URL or tab bars.

Handle the Drag-and-Drop Events