fixed SSR
This commit is contained in:
parent
801a9c9d6d
commit
4cccdf1fd5
2 changed files with 14 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
import handleEscapeMixin from './handleEscapeMixin';
|
import handleEscapeMixin from './handleEscapeMixin';
|
||||||
import {getTouches} from './utils';
|
import {getTouches} from './utils';
|
||||||
|
import { on, off } from '../../utils/dom';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [Emitter, handleEscapeMixin],
|
mixins: [Emitter, handleEscapeMixin],
|
||||||
|
@ -42,15 +43,19 @@ export default {
|
||||||
handleMouseDown(e) {
|
handleMouseDown(e) {
|
||||||
this.dispatch('ColorPicker', 'on-dragging', true);
|
this.dispatch('ColorPicker', 'on-dragging', true);
|
||||||
this.handleChange(e, true);
|
this.handleChange(e, true);
|
||||||
window.addEventListener('mousemove', this.handleChange, false);
|
// window.addEventListener('mousemove', this.handleChange, false);
|
||||||
window.addEventListener('mouseup', this.handleMouseUp, false);
|
// window.addEventListener('mouseup', this.handleMouseUp, false);
|
||||||
|
on(window, 'mousemove', this.handleChange);
|
||||||
|
on(window, 'mouseup', this.handleMouseUp);
|
||||||
},
|
},
|
||||||
handleMouseUp() {
|
handleMouseUp() {
|
||||||
this.unbindEventListeners();
|
this.unbindEventListeners();
|
||||||
},
|
},
|
||||||
unbindEventListeners() {
|
unbindEventListeners() {
|
||||||
window.removeEventListener('mousemove', this.handleChange);
|
// window.removeEventListener('mousemove', this.handleChange);
|
||||||
window.removeEventListener('mouseup', this.handleMouseUp);
|
// window.removeEventListener('mouseup', this.handleMouseUp);
|
||||||
|
off(window, 'mousemove', this.handleChange);
|
||||||
|
off(window, 'mouseup', this.handleMouseUp);
|
||||||
// This timeout is required so that the click handler for click-outside
|
// This timeout is required so that the click handler for click-outside
|
||||||
// has the chance to run before the mouseup removes the dragging flag.
|
// has the chance to run before the mouseup removes the dragging flag.
|
||||||
setTimeout(() => this.dispatch('ColorPicker', 'on-dragging', false), 1);
|
setTimeout(() => this.dispatch('ColorPicker', 'on-dragging', false), 1);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
import HSAMixin from './hsaMixin';
|
import HSAMixin from './hsaMixin';
|
||||||
import Prefixes from './prefixMixin';
|
import Prefixes from './prefixMixin';
|
||||||
import {clamp, getIncrement} from './utils';
|
import {clamp, getIncrement} from './utils';
|
||||||
|
import { on, off } from '../../utils/dom';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Saturation',
|
name: 'Saturation',
|
||||||
|
@ -87,11 +88,13 @@ export default {
|
||||||
},
|
},
|
||||||
handleMouseDown(e) {
|
handleMouseDown(e) {
|
||||||
HSAMixin.methods.handleMouseDown.call(this, e);
|
HSAMixin.methods.handleMouseDown.call(this, e);
|
||||||
window.addEventListener('mouseup', this.handleChange, false);
|
// window.addEventListener('mouseup', this.handleChange, false);
|
||||||
|
on(window, 'mouseup', this.handleChange);
|
||||||
},
|
},
|
||||||
unbindEventListeners(e) {
|
unbindEventListeners(e) {
|
||||||
HSAMixin.methods.unbindEventListeners.call(this, e);
|
HSAMixin.methods.unbindEventListeners.call(this, e);
|
||||||
window.removeEventListener('mouseup', this.handleChange);
|
// window.removeEventListener('mouseup', this.handleChange);
|
||||||
|
off(window, 'mouseup', this.handleChange);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue