Skip to content

Commit 1f50e35

Browse files
chore: removes events mixin.
1 parent 30b9f5d commit 1f50e35

File tree

2 files changed

+56
-80
lines changed

2 files changed

+56
-80
lines changed

addon/mixins/events-mixin.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

addon/mixins/focusable-mixin.js

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
/* eslint-disable prettier/prettier */
21
/**
32
* @module ember-paper
43
*/
54
import Mixin from '@ember/object/mixin';
6-
75
import { computed } from '@ember/object';
8-
import EventsMixin from './events-mixin';
96
import { invokeAction } from 'ember-paper/utils/invoke-action';
107

118
/**
129
* @class FocusableMixin
1310
* @extends Ember.Mixin
14-
* @uses EventsMixin
1511
*/
16-
export default Mixin.create(EventsMixin, {
17-
12+
export default Mixin.create({
1813
disabled: false,
1914
pressed: false,
2015
active: false,
@@ -24,12 +19,12 @@ export default Mixin.create(EventsMixin, {
2419
classNameBindings: ['focused:md-focused'],
2520
attributeBindings: ['tabindex', 'disabledAttr:disabled'],
2621

27-
disabledAttr: computed('disabled', function() {
22+
disabledAttr: computed('disabled', function () {
2823
return this.disabled ? 'disabled' : null;
2924
}),
3025

31-
// Alow element to be focusable by supplying a tabindex 0
32-
tabindex: computed('disabled', function() {
26+
// Allow element to be focusable by supplying a tabindex 0
27+
tabindex: computed('disabled', function () {
3328
return this.disabled ? '-1' : '0';
3429
}),
3530

@@ -40,25 +35,30 @@ export default Mixin.create(EventsMixin, {
4035
focusOnlyOnKey: false,
4136

4237
_mouseEnterHandler: undefined,
38+
_mouseMoveHandler: undefined,
4339
_mouseLeaveHandler: undefined,
4440

4541
didInsertElement() {
4642
this._super(...arguments);
4743

4844
this._mouseEnterHandler = this.handleMouseEnter.bind(this);
45+
this._mouseMoveHandler = this.handleMouseMove.bind(this);
4946
this._mouseLeaveHandler = this.handleMouseLeave.bind(this);
5047

5148
this.element.addEventListener('mouseenter', this._mouseEnterHandler);
49+
this.element.addEventListener('mousemove', this._mouseMoveHandler);
5250
this.element.addEventListener('mouseleave', this._mouseLeaveHandler);
5351
},
5452

5553
willDestroyElement() {
5654
this._super(...arguments);
5755

5856
this.element.removeEventListener('mouseenter', this._mouseEnterHandler);
57+
this.element.removeEventListener('mousemove', this._mouseMoveHandler);
5958
this.element.removeEventListener('mouseleave', this._mouseLeaveHandler);
6059

6160
this._mouseEnterHandler = undefined;
61+
this._mouseMoveHandler = undefined;
6262
this._mouseLeaveHandler = undefined;
6363
},
6464

@@ -68,7 +68,7 @@ export default Mixin.create(EventsMixin, {
6868
* They bubble by default.
6969
*/
7070
focusIn() {
71-
if (!this.disabled && !this.focusOnlyOnKey || !this.pressed) {
71+
if ((!this.disabled && !this.focusOnlyOnKey) || !this.pressed) {
7272
this.set('focused', true);
7373
}
7474
},
@@ -82,12 +82,40 @@ export default Mixin.create(EventsMixin, {
8282
invokeAction(this, 'onMouseEnter', e);
8383
},
8484

85+
touchStart(e) {
86+
return this.down(e);
87+
},
88+
89+
mouseDown(e) {
90+
this.down(e);
91+
},
92+
93+
touchEnd(e) {
94+
return this.up(e);
95+
},
96+
97+
mouseUp(e) {
98+
return this.up(e);
99+
},
100+
101+
touchCancel(e) {
102+
return this.up(e);
103+
},
104+
85105
handleMouseLeave(e) {
86106
this.set('hover', false);
87-
this._super(e);
107+
this.up(e);
88108
invokeAction(this, 'onMouseLeave', e);
89109
},
90110

111+
up() {
112+
this.set('pressed', false);
113+
114+
if (!this.toggle) {
115+
this.set('active', false);
116+
}
117+
},
118+
91119
down() {
92120
this.set('pressed', true);
93121
if (this.toggle) {
@@ -96,12 +124,23 @@ export default Mixin.create(EventsMixin, {
96124
this.set('active', true);
97125
}
98126
},
127+
contextMenu() {},
99128

100-
up() {
101-
this.set('pressed', false);
129+
/*
130+
* Move events
131+
*/
102132

103-
if (!this.toggle) {
104-
this.set('active', false);
105-
}
106-
}
133+
handleMouseMove(e) {
134+
return this.move(e);
135+
},
136+
137+
touchMove(e) {
138+
return this.move(e);
139+
},
140+
141+
pointerMove(e) {
142+
return this.move(e);
143+
},
144+
145+
move() {},
107146
});

0 commit comments

Comments
 (0)