Commit 4cccdf1fd56d56c576c2020368fa3957801a81e9
1 parent
801a9c9d
fixed SSR
Showing
2 changed files
with
14 additions
and
6 deletions
Show diff stats
src/components/color-picker/hsaMixin.js
1 | import Emitter from '../../mixins/emitter'; | 1 | import Emitter from '../../mixins/emitter'; |
2 | import handleEscapeMixin from './handleEscapeMixin'; | 2 | import handleEscapeMixin from './handleEscapeMixin'; |
3 | import {getTouches} from './utils'; | 3 | import {getTouches} from './utils'; |
4 | +import { on, off } from '../../utils/dom'; | ||
4 | 5 | ||
5 | export default { | 6 | export default { |
6 | mixins: [Emitter, handleEscapeMixin], | 7 | mixins: [Emitter, handleEscapeMixin], |
@@ -42,15 +43,19 @@ export default { | @@ -42,15 +43,19 @@ export default { | ||
42 | handleMouseDown(e) { | 43 | handleMouseDown(e) { |
43 | this.dispatch('ColorPicker', 'on-dragging', true); | 44 | this.dispatch('ColorPicker', 'on-dragging', true); |
44 | this.handleChange(e, true); | 45 | this.handleChange(e, true); |
45 | - window.addEventListener('mousemove', this.handleChange, false); | ||
46 | - window.addEventListener('mouseup', this.handleMouseUp, false); | 46 | + // window.addEventListener('mousemove', this.handleChange, false); |
47 | + // window.addEventListener('mouseup', this.handleMouseUp, false); | ||
48 | + on(window, 'mousemove', this.handleChange); | ||
49 | + on(window, 'mouseup', this.handleMouseUp); | ||
47 | }, | 50 | }, |
48 | handleMouseUp() { | 51 | handleMouseUp() { |
49 | this.unbindEventListeners(); | 52 | this.unbindEventListeners(); |
50 | }, | 53 | }, |
51 | unbindEventListeners() { | 54 | unbindEventListeners() { |
52 | - window.removeEventListener('mousemove', this.handleChange); | ||
53 | - window.removeEventListener('mouseup', this.handleMouseUp); | 55 | + // window.removeEventListener('mousemove', this.handleChange); |
56 | + // window.removeEventListener('mouseup', this.handleMouseUp); | ||
57 | + off(window, 'mousemove', this.handleChange); | ||
58 | + off(window, 'mouseup', this.handleMouseUp); | ||
54 | // This timeout is required so that the click handler for click-outside | 59 | // This timeout is required so that the click handler for click-outside |
55 | // has the chance to run before the mouseup removes the dragging flag. | 60 | // has the chance to run before the mouseup removes the dragging flag. |
56 | setTimeout(() => this.dispatch('ColorPicker', 'on-dragging', false), 1); | 61 | setTimeout(() => this.dispatch('ColorPicker', 'on-dragging', false), 1); |
src/components/color-picker/saturation.vue
@@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
29 | import HSAMixin from './hsaMixin'; | 29 | import HSAMixin from './hsaMixin'; |
30 | import Prefixes from './prefixMixin'; | 30 | import Prefixes from './prefixMixin'; |
31 | import {clamp, getIncrement} from './utils'; | 31 | import {clamp, getIncrement} from './utils'; |
32 | +import { on, off } from '../../utils/dom'; | ||
32 | 33 | ||
33 | export default { | 34 | export default { |
34 | name: 'Saturation', | 35 | name: 'Saturation', |
@@ -87,11 +88,13 @@ export default { | @@ -87,11 +88,13 @@ export default { | ||
87 | }, | 88 | }, |
88 | handleMouseDown(e) { | 89 | handleMouseDown(e) { |
89 | HSAMixin.methods.handleMouseDown.call(this, e); | 90 | HSAMixin.methods.handleMouseDown.call(this, e); |
90 | - window.addEventListener('mouseup', this.handleChange, false); | 91 | +// window.addEventListener('mouseup', this.handleChange, false); |
92 | + on(window, 'mouseup', this.handleChange); | ||
91 | }, | 93 | }, |
92 | unbindEventListeners(e) { | 94 | unbindEventListeners(e) { |
93 | HSAMixin.methods.unbindEventListeners.call(this, e); | 95 | HSAMixin.methods.unbindEventListeners.call(this, e); |
94 | - window.removeEventListener('mouseup', this.handleChange); | 96 | +// window.removeEventListener('mouseup', this.handleChange); |
97 | + off(window, 'mouseup', this.handleChange); | ||
95 | }, | 98 | }, |
96 | }, | 99 | }, |
97 | }; | 100 | }; |