mirror of
https://github.com/PitPik/tinyColorPicker
synced 2025-07-02 23:54:29 -06:00
stay in view-port support for scroll and resize
…and $trigger in colorPicker model
This commit is contained in:
parent
e8e2874588
commit
233ea3d05b
@ -49,6 +49,7 @@ $('.color').colorPicker({
|
|||||||
css: '', // replaces existing css
|
css: '', // replaces existing css
|
||||||
cssAddon: '', // adds css to existing
|
cssAddon: '', // adds css to existing
|
||||||
margin: '', // positioning margin (can also be set in cssAddon)
|
margin: '', // positioning margin (can also be set in cssAddon)
|
||||||
|
scrollResize: true // toggle for reposition colorPicker on window.resize/scroll
|
||||||
preventFocus: false // prevents default on focus of input fields,
|
preventFocus: false // prevents default on focus of input fields,
|
||||||
body: document.body // the element where the events are attached to (touchstart, mousedown, pointerdown, focus, click, change)
|
body: document.body // the element where the events are attached to (touchstart, mousedown, pointerdown, focus, click, change)
|
||||||
});
|
});
|
||||||
@ -73,6 +74,7 @@ colors.js is a quite handy tool for color calculations/conversion (gray value, c
|
|||||||
If you need more complex calculations or more color spaces, use the version from https://github.com/PitPik/colorPicker. It supports also cmy, cmyk, XYZ and Lab.
|
If you need more complex calculations or more color spaces, use the version from https://github.com/PitPik/colorPicker. It supports also cmy, cmyk, XYZ and Lab.
|
||||||
```javascript
|
```javascript
|
||||||
myColorPicker: {
|
myColorPicker: {
|
||||||
|
$trigger: ... // jQuery object of active trigger or null if none active
|
||||||
color: { // instance of Color inside colorPicker
|
color: { // instance of Color inside colorPicker
|
||||||
colors: { all kinds of color values... see later},
|
colors: { all kinds of color values... see later},
|
||||||
options: { all the options you set or that are set as default... },
|
options: { all the options you set or that are set as default... },
|
||||||
|
@ -94,9 +94,9 @@ window.myColorPicker = $('input.color').colorPicker({
|
|||||||
|
|
||||||
<!-- <script type="text/javascript" src="jquery-1.11.2.js"></script> -->
|
<!-- <script type="text/javascript" src="jquery-1.11.2.js"></script> -->
|
||||||
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
|
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
|
||||||
<!-- <script type="text/javascript" src="colors.js"></script> -->
|
<script type="text/javascript" src="colors.js"></script>
|
||||||
<!-- <script type="text/javascript" src="jqColorPicker.js"></script> -->
|
<script type="text/javascript" src="jqColorPicker.js"></script>
|
||||||
<script type="text/javascript" src="jqColorPicker.min.js"></script>
|
<!-- <script type="text/javascript" src="jqColorPicker.min.js"></script> -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function(window, undefined){
|
(function(window, undefined){
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -506,7 +506,7 @@ window.myColorPicker = $('input.color').colorPicker({
|
|||||||
e.stopPropagation && e.stopPropagation();
|
e.stopPropagation && e.stopPropagation();
|
||||||
that.toggle();
|
that.toggle();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
cssAddon: // could also be in a css file instead
|
cssAddon: // could also be in a css file instead
|
||||||
|
@ -66,12 +66,12 @@
|
|||||||
|
|
||||||
function toggle(event) {
|
function toggle(event) {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
position,
|
position = $this.offset(),
|
||||||
$window = $(window);
|
$window = $(window);
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
position = $this.offset();
|
|
||||||
_$trigger = findElement($this);
|
_$trigger = findElement($this);
|
||||||
|
_colorPicker.$trigger = $this;
|
||||||
|
|
||||||
(_$UI || build()).css({
|
(_$UI || build()).css({
|
||||||
'left': !(_$UI[0]._right = position.left + _$UI[0]._width >
|
'left': !(_$UI[0]._right = position.left + _$UI[0]._width >
|
||||||
@ -93,6 +93,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$(_$UI).hide(_options.animationSpeed, function() {
|
$(_$UI).hide(_options.animationSpeed, function() {
|
||||||
_$trigger.blur();
|
_$trigger.blur();
|
||||||
|
_colorPicker.$trigger = null;
|
||||||
preRender(false);
|
preRender(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -252,13 +253,20 @@
|
|||||||
opacity: true,
|
opacity: true,
|
||||||
renderCallback: noop,
|
renderCallback: noop,
|
||||||
buidCallback: noop,
|
buidCallback: noop,
|
||||||
body: document.body
|
body: document.body,
|
||||||
|
scrollResize: true
|
||||||
// css: '',
|
// css: '',
|
||||||
// cssAddon: '',
|
// cssAddon: '',
|
||||||
// margin: '',
|
// margin: '',
|
||||||
// preventFocus: false
|
// preventFocus: false
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
|
!_colorPicker && options.scrollResize && $(window).
|
||||||
|
on('resize scroll', function() {
|
||||||
|
if (_colorPicker.$trigger) {
|
||||||
|
_colorPicker.toggle.call(_colorPicker.$trigger[0], true);
|
||||||
|
}
|
||||||
|
});
|
||||||
_instance = _instance ? _instance.add(this) : this;
|
_instance = _instance ? _instance.add(this) : this;
|
||||||
_instance.colorPicker = _colorPicker ||
|
_instance.colorPicker = _colorPicker ||
|
||||||
(_colorPicker = new ColorPicker(options));
|
(_colorPicker = new ColorPicker(options));
|
||||||
|
File diff suppressed because one or more lines are too long
2
jqColorPicker.min.js
vendored
2
jqColorPicker.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user