diff --git a/package.json b/package.json index b132a21..287bc97 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "detect-browser": "^4.5.0", "file-saver": "^1.3.8", "jsonlint": "github:josdejong/jsonlint#85a19d7", + "lodash": "^4.17.15", "lodash.capitalize": "^4.2.1", "lodash.clamp": "^4.0.3", "lodash.clonedeep": "^4.5.0", diff --git a/src/components/fields/ColorField.jsx b/src/components/fields/ColorField.jsx index f1f6077..7a974f1 100644 --- a/src/components/fields/ColorField.jsx +++ b/src/components/fields/ColorField.jsx @@ -2,6 +2,7 @@ import React from 'react' import Color from 'color' import ChromePicker from 'react-color/lib/components/chrome/Chrome' import PropTypes from 'prop-types' +import lodash from 'lodash'; function formatColor(color) { const rgb = color.rgb @@ -23,6 +24,15 @@ class ColorField extends React.Component { pickerOpened: false } + constructor () { + super(); + this.onChangeNoCheck = lodash.throttle(this.onChangeNoCheck, 1000/30); + } + + onChangeNoCheck (v) { + this.props.onChange(formatColor(v)); + } + //TODO: I much rather would do this with absolute positioning //but I am too stupid to get it to work together with fixed position //and scrollbars so I have to fallback to JavaScript @@ -82,7 +92,7 @@ class ColorField extends React.Component { }}> this.props.onChange(formatColor(c))} + onChange={c => this.onChangeNoCheck(formatColor(c))} />