Last active
July 6, 2017 06:35
-
-
Save siva-sundar/d20d004cd35ea4c7cda829db92e54e9e to your computer and use it in GitHub Desktop.
Drag demo
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['draggable'], | |
attributeBindings: ['draggable'], | |
draggable: true, | |
didInsertElement() { | |
this._super(...arguments); | |
document.addEventListener('mouseover', (event) => { | |
console.log(event); | |
if (this.isElementBeingDragged) { | |
event = event.originalEvent || event; | |
let { x: top, y: left } = event; | |
console.log(top, left); | |
this.$().css({ | |
top, | |
right: 'initial', | |
left, | |
right: 'initial', | |
'user-select': 'initial' | |
}); | |
this.isElementBeingDragged = false; | |
} | |
}); | |
}, | |
mouseDown(event) { | |
//this._super(...arguments); | |
this.isElementBeingDragged = true; | |
this.$().css('user-select', 'none'); | |
}, | |
}); |
This file contains hidden or 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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or 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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 14px; | |
} | |
.container { | |
position: absolute; | |
top: 70px; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
width: 100%; | |
border: 1px solid | |
} | |
.draggable { | |
position: fixed; | |
top: 0px; | |
left: 0px; | |
width: 60px; | |
height: 60px; | |
border: 1px solid red; | |
} |
This file contains hidden or 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.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment