-
-
Save stansidel/9db4b94fe7f4e65b6dab0fe7474e3b5a to your computer and use it in GitHub Desktop.
Simple Drag Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@glimmer/component'; | |
import { action } from '@ember/object'; | |
import { tracked } from '@glimmer/tracking'; | |
export default class SimpleDrag extends Component { | |
@tracked statusText = ""; | |
@tracked overDropZone = false; | |
@action dragHasStarted() { | |
this.statusText = "Drag has started"; | |
} | |
@action dropItem(dragEvent) { | |
dragEvent.preventDefault(); | |
this.statusText = "Drop Has Completed"; | |
this.overDropZone = false; | |
} | |
@action dragOver(dragEvent) { | |
dragEvent.preventDefault(); | |
dragEvent.dataTransfer.dropEffect = "move"; | |
} | |
@action dropLeave() { | |
this.statusText = "Drag has left drop zone"; | |
this.overDropZone = false; | |
} | |
@action dropEnter() { | |
this.statusText = "Drag is entered Drop Zone"; | |
this.overDropZone = true; | |
} | |
@action dragEnd() { | |
this.statusText += "; Drag end"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dropZone { | |
padding: 10px; | |
background-color: #CCC; | |
width: 200px; | |
text-align: center; | |
border: 1px solid #fff; | |
margin-bottom: 24px; | |
} | |
.dropZone-over { | |
border: 1px dashed #333; | |
background-color: rgb(193, 211, 159); | |
} | |
.dragMe { | |
width: 200px; | |
padding: 10px; | |
background-color: #333; | |
color: white; | |
text-align: center; | |
cursor:move; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.17.0", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.17.0", | |
"ember-template-compiler": "3.17.0", | |
"ember-testing": "3.17.0" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment