SlideShare una empresa de Scribd logo
1 de 15
By Anney
 將 yellow 搬移至 blue 。
 blue 允許放入 yellow , red 不允許放。
 進入 blue 時, blue 要改變 border size 與 color




                               01/07/13     2
   將黃色區塊拖拉至藍色區塊
    ◦ 允許 yellow 可以被拖拉。
    ◦ over blue, add style
      border: solid 2px red;
    ◦ out blue, remove border style.
    ◦ drop into blue, move yellow to blue.




                                             01/07/13   3
   draggable attribute
    ◦ boolean
    ◦ text selections, images and links 預設為
      true, 其餘 element 預設為 false 。




                                              01/07/13   4
   blue - ondragenter




                         01/07/13   5
   blue - ondragleave




                         01/07/13   6
   blue – ondrop, ondragover




   red – ondragstart




                                01/07/13   7
   event 會在拖曳的不同階段被觸發。值得注意的是
    僅有 drag event 會發生,其他的滑鼠事件
    ( 如 mousemove) 是不會發生的。
    ◦   dragstart (source)
    ◦   drag (source)
    ◦   dragenter (target)
    ◦   dragover (target)
    ◦   dagleave (target)
    ◦   dragend (source)
    ◦   drop (target)


                             01/07/13   8
 dataTransfer object
 preventDefault method




                          01/07/13   9
 All drag events have a property called 
  dataTransfer which is used to hold the drag data.
 The DataTransfer object is used to hold the data

  that is being dragged during a drag and drop
  operation. It may hold one or more data items,
  each of one or more data types.




                                        01/07/13      10
void addElement(in Element element)
void clearData([in String type])
String getData(in String type)
void setData(in String type, in String data)
void setDragImage(in nsIDOMElement image, in long x, in long y)

ps.
nsIDOMElement: This interface represents an element in an HTML or XML document.




                                                                          01/07/13   11
01/07/13   12
 必須適時執行這個方法,來避免預設的動作被執行
  。
 非輸入的 Element dragover 事件 , 預設不允許

  Drop 。
    ◦ ondragover 中一定要執行 preventDefault() , ondrop
      事件才會被觸發。




                                        01/07/13    13
 https://
  developer.mozilla.org/zh-TW/docs/DragDrop/Drag_and
 https://

  developer.mozilla.org/en-US/docs/DragDrop/Drag_Ope
 http://

  www.w3schools.com/html/html5_draganddrop.asp
 http://zh.wikipedia.org/wiki/Gecko




                                     01/07/13   14
01/07/13   15

Más contenido relacionado

Más de LearningTech (20)

Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection & activator
Reflection & activatorReflection & activator
Reflection & activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 
Vic weekly learning_20151127
Vic weekly learning_20151127Vic weekly learning_20151127
Vic weekly learning_20151127
 
Mocha.js
Mocha.jsMocha.js
Mocha.js
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

20121108 html5 drag_drop

  • 2.  將 yellow 搬移至 blue 。  blue 允許放入 yellow , red 不允許放。  進入 blue 時, blue 要改變 border size 與 color 01/07/13 2
  • 3. 將黃色區塊拖拉至藍色區塊 ◦ 允許 yellow 可以被拖拉。 ◦ over blue, add style  border: solid 2px red; ◦ out blue, remove border style. ◦ drop into blue, move yellow to blue. 01/07/13 3
  • 4. draggable attribute ◦ boolean ◦ text selections, images and links 預設為 true, 其餘 element 預設為 false 。 01/07/13 4
  • 5. blue - ondragenter 01/07/13 5
  • 6. blue - ondragleave 01/07/13 6
  • 7. blue – ondrop, ondragover  red – ondragstart 01/07/13 7
  • 8. event 會在拖曳的不同階段被觸發。值得注意的是 僅有 drag event 會發生,其他的滑鼠事件 ( 如 mousemove) 是不會發生的。 ◦ dragstart (source) ◦ drag (source) ◦ dragenter (target) ◦ dragover (target) ◦ dagleave (target) ◦ dragend (source) ◦ drop (target) 01/07/13 8
  • 9.  dataTransfer object  preventDefault method 01/07/13 9
  • 10.  All drag events have a property called  dataTransfer which is used to hold the drag data.  The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. 01/07/13 10
  • 12. 01/07/13 12
  • 13.  必須適時執行這個方法,來避免預設的動作被執行 。  非輸入的 Element dragover 事件 , 預設不允許 Drop 。 ◦ ondragover 中一定要執行 preventDefault() , ondrop 事件才會被觸發。 01/07/13 13
  • 14.  https:// developer.mozilla.org/zh-TW/docs/DragDrop/Drag_and  https:// developer.mozilla.org/en-US/docs/DragDrop/Drag_Ope  http:// www.w3schools.com/html/html5_draganddrop.asp  http://zh.wikipedia.org/wiki/Gecko 01/07/13 14
  • 15. 01/07/13 15