Guest User

Untitled

a guest
Nov 16th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. export default Ember.Component.extend({
  4.  
  5. didInsertElement(){
  6. this._super(...arguments);
  7. const box = $('#box');
  8. this.set('_box', box);
  9.  
  10. $('#handle').on('mousedown', (e) => {
  11. $(window).on('mousemove', this.startResizing.bind(this));
  12. $(window).on('mouseup', this.stopResizing.bind(this));
  13. });
  14. },
  15.  
  16. willDestroyElement(){
  17. this._super(...arguments);
  18. this.stopResizing();
  19. },
  20.  
  21. startResizing(e) {
  22. const box = this.get('_box')
  23. const offset = box.offset();
  24. box.width(e.clientX + offset.left);
  25. box.height(e.clientY + offset.top);
  26. },
  27.  
  28. stopResizing() {
  29. $(window).off('mousemove');
  30. $(window).off('mouseup');
  31. }
  32.  
  33. });
Add Comment
Please, Sign In to add comment