mirror of
https://github.com/PitPik/tinyColorPicker
synced 2025-07-15 22:14:28 -06:00
fit in view-port update
This commit is contained in:
parent
233ea3d05b
commit
167c422c5e
@ -50,6 +50,7 @@ $('.color').colorPicker({
|
|||||||
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
|
scrollResize: true // toggle for reposition colorPicker on window.resize/scroll
|
||||||
|
gap: 4 // gap to right and bottom edge of view port if repositioned to fit
|
||||||
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)
|
||||||
});
|
});
|
||||||
|
@ -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';
|
||||||
@ -187,6 +187,7 @@ window.myColorPicker = $('input.color').colorPicker({
|
|||||||
},
|
},
|
||||||
|
|
||||||
cssAddon: // could also be in a css file instead
|
cssAddon: // could also be in a css file instead
|
||||||
|
'.cp-color-picker{width:226px;}' +
|
||||||
'.cp-color-picker .cp-panel {line-height: 21px; float:right;' +
|
'.cp-color-picker .cp-panel {line-height: 21px; float:right;' +
|
||||||
'padding:0 1px 0 8px; margin-top:-1px; overflow:visible}' +
|
'padding:0 1px 0 8px; margin-top:-1px; overflow:visible}' +
|
||||||
'.cp-xy-slider:active {cursor:none;}' +
|
'.cp-xy-slider:active {cursor:none;}' +
|
||||||
@ -198,7 +199,7 @@ window.myColorPicker = $('input.color').colorPicker({
|
|||||||
'.cp-panel hr {margin:0 -2px 2px; height:1px; border:0;' +
|
'.cp-panel hr {margin:0 -2px 2px; height:1px; border:0;' +
|
||||||
'background:#666; border-top:1px solid #222;}' +
|
'background:#666; border-top:1px solid #222;}' +
|
||||||
'.cp-panel .cp-HEX {width:44px; position:absolute; margin:1px -3px 0 -2px;}' +
|
'.cp-panel .cp-HEX {width:44px; position:absolute; margin:1px -3px 0 -2px;}' +
|
||||||
'.cp-alpha {width:154px;}',
|
'.cp-alpha {width:155px;}',
|
||||||
|
|
||||||
renderCallback: function($elm, toggled) {
|
renderCallback: function($elm, toggled) {
|
||||||
var colors = this.color.colors.RND,
|
var colors = this.color.colors.RND,
|
||||||
|
@ -67,22 +67,27 @@
|
|||||||
function toggle(event) {
|
function toggle(event) {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
position = $this.offset(),
|
position = $this.offset(),
|
||||||
$window = $(window);
|
$window = $(window),
|
||||||
|
gap = _options.gap;
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
_$trigger = findElement($this);
|
_$trigger = findElement($this);
|
||||||
_colorPicker.$trigger = $this;
|
_colorPicker.$trigger = $this;
|
||||||
|
|
||||||
(_$UI || build()).css({
|
(_$UI || build()).css({
|
||||||
'left': !(_$UI[0]._right = position.left + _$UI[0]._width >
|
'width': _$UI[0]._width,
|
||||||
$window.scrollLeft() + $window.width() ? 4 : '') ?
|
'left': (_$UI[0]._left = position.left) -
|
||||||
position.left : '',
|
((_$UI[0]._left = _$UI[0]._left + _$UI[0]._width -
|
||||||
'right': _$UI[0]._right,
|
($window.scrollLeft() + $window.width())) + gap > 0 ?
|
||||||
|
_$UI[0]._left + gap : 0),
|
||||||
'top': (_$UI[0]._top = position.top + $this.outerHeight()) -
|
'top': (_$UI[0]._top = position.top + $this.outerHeight()) -
|
||||||
((_$UI[0]._top = _$UI[0]._top + _$UI[0]._height -
|
((_$UI[0]._top = _$UI[0]._top + _$UI[0]._height -
|
||||||
($window.scrollTop() + $window.height())) > 0 ?
|
($window.scrollTop() + $window.height())) + gap > 0 ?
|
||||||
_$UI[0]._top + 8 : 0)
|
_$UI[0]._top + gap : 0)
|
||||||
}).show(_options.animationSpeed, function() {
|
}).show(_options.animationSpeed, function() {
|
||||||
|
if (event === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_$alpha._width = _$alpha.width();
|
_$alpha._width = _$alpha.width();
|
||||||
_$xy_slider._width = _$xy_slider.width();
|
_$xy_slider._width = _$xy_slider.width();
|
||||||
_$xy_slider._height = _$xy_slider.height();
|
_$xy_slider._height = _$xy_slider.height();
|
||||||
@ -103,7 +108,8 @@
|
|||||||
$('head').append('<style type="text/css">' +
|
$('head').append('<style type="text/css">' +
|
||||||
(_options.css || _css) + (_options.cssAddon || '') + '</style>');
|
(_options.css || _css) + (_options.cssAddon || '') + '</style>');
|
||||||
|
|
||||||
return _$UI = $(_html).css({'margin': _options.margin}).
|
return _$UI = $(_html).css({'margin': _options.margin,
|
||||||
|
'box-sizing': 'border-box'}).
|
||||||
appendTo('body').
|
appendTo('body').
|
||||||
show(0, function() {
|
show(0, function() {
|
||||||
_GPU = _options.GPU && $(this).css('perspective') === '';
|
_GPU = _options.GPU && $(this).css('perspective') === '';
|
||||||
@ -254,7 +260,8 @@
|
|||||||
renderCallback: noop,
|
renderCallback: noop,
|
||||||
buidCallback: noop,
|
buidCallback: noop,
|
||||||
body: document.body,
|
body: document.body,
|
||||||
scrollResize: true
|
scrollResize: true,
|
||||||
|
gap: 4
|
||||||
// css: '',
|
// css: '',
|
||||||
// cssAddon: '',
|
// cssAddon: '',
|
||||||
// margin: '',
|
// margin: '',
|
||||||
|
File diff suppressed because one or more lines are too long
4
jqColorPicker.min.js
vendored
4
jqColorPicker.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user