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 | 1 | import Emitter from '../../mixins/emitter'; |
2 | 2 | import handleEscapeMixin from './handleEscapeMixin'; |
3 | 3 | import {getTouches} from './utils'; |
4 | +import { on, off } from '../../utils/dom'; | |
4 | 5 | |
5 | 6 | export default { |
6 | 7 | mixins: [Emitter, handleEscapeMixin], |
... | ... | @@ -42,15 +43,19 @@ export default { |
42 | 43 | handleMouseDown(e) { |
43 | 44 | this.dispatch('ColorPicker', 'on-dragging', true); |
44 | 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 | 51 | handleMouseUp() { |
49 | 52 | this.unbindEventListeners(); |
50 | 53 | }, |
51 | 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 | 59 | // This timeout is required so that the click handler for click-outside |
55 | 60 | // has the chance to run before the mouseup removes the dragging flag. |
56 | 61 | setTimeout(() => this.dispatch('ColorPicker', 'on-dragging', false), 1); | ... | ... |
src/components/color-picker/saturation.vue
... | ... | @@ -29,6 +29,7 @@ |
29 | 29 | import HSAMixin from './hsaMixin'; |
30 | 30 | import Prefixes from './prefixMixin'; |
31 | 31 | import {clamp, getIncrement} from './utils'; |
32 | +import { on, off } from '../../utils/dom'; | |
32 | 33 | |
33 | 34 | export default { |
34 | 35 | name: 'Saturation', |
... | ... | @@ -87,11 +88,13 @@ export default { |
87 | 88 | }, |
88 | 89 | handleMouseDown(e) { |
89 | 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 | 94 | unbindEventListeners(e) { |
93 | 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 | }; | ... | ... |