avoid carrot to jump

pull/25/head
peterd 9 years ago
parent 11e0a4ed4f
commit 6f7fd42860

@ -112,6 +112,7 @@ window.myColorPicker = $('input.color').colorPicker({
margin: '4px -2px', margin: '4px -2px',
doRender: 'div div', doRender: 'div div',
preventFocus: true, preventFocus: true,
animationSpeed: 0,
// demo on how to make plugins... mobile support plugin // demo on how to make plugins... mobile support plugin
buidCallback: function($elm) { buidCallback: function($elm) {

@ -64,6 +64,8 @@
position; position;
if (event) { if (event) {
// if (this.nodeName.toLowerCase() === 'input' &&
// event.type === 'click') return;
// _options.preventFocus && this.blur(); // _options.preventFocus && this.blur();
position = $this.offset(); position = $this.offset();
_cache.$element = findElement($this); _cache.$element = findElement($this);
@ -161,7 +163,8 @@
HSL = colors.RND.hsl, HSL = colors.RND.hsl,
dark = '#222', dark = '#222',
light = '#ddd', light = '#ddd',
colorMode = _cache.$element.data('colorMode'), $element = _cache.$element,
colorMode = $element.data('colorMode'),
isAlpha = colors.alpha !== 1, isAlpha = colors.alpha !== 1,
alpha = Math.round(colors.alpha * 100) / 100, alpha = Math.round(colors.alpha * 100) / 100,
RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b, RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b,
@ -199,12 +202,12 @@
left: !_GPU ? a : '', left: !_GPU ? a : '',
borderColor : alphaContrast + ' transparent' borderColor : alphaContrast + ' transparent'
}); });
_options.doRender && _cache.$element.css({ _options.doRender && $element.css({
backgroundColor : text, backgroundColor : text,
color: colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light color: colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light
}); });
_cache.$element.val(text); $element.val() !== text && $element.val(text); // avoids carret jump
// faster version (more than 2.5x)... though, no jQuery (colors, ...) // faster version (more than 2.5x)... though, no jQuery (colors, ...)
@ -234,7 +237,7 @@
_options.renderCallback.call( _options.renderCallback.call(
_colorPicker, _colorPicker,
_cache.$element, $element,
typeof toggled === 'boolean' ? toggled : undefined typeof toggled === 'boolean' ? toggled : undefined
); );
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save