# j-FloatingPanel

> You can combine methods with j-Shortcuts component.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 45ba6e92b0aa5454f04971ad8204afac4a82864bd9ebc1e20173c2fc295f873a
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- singleton
- supports custom scrollbars
- supports __dark mode__

__Methods__:

Method: `component.show(options)`

- `options.element {Element/jQuery Element}`
- `options.offsetX {Number}` optional, `x` offset (default: `0`)
- `options.offsetY {Number}` optional, `y` offset (default: `0`)
- `options.offsetWidth {Number}` optional, `width` offset (default: `0`)
- `options.minwidth {Number}` optional, a minimal width (default `200`)
- `options.maxwidth {Number}` optional, a maximal width (default `infinite`)
- `options.height {Number}` optional, a height (default: `200`)
- `options.callback(element) {Function}` is triggered when the user clicks on the element with `.selectable` class
- `options.init {Function}` is triggered before the component is displayed
- `options.close {Function}` optional, can determine closing of panel
- `options.align {String}` optional, `left` (default), `right` or `center`
- `options.position {String}` optional, `top` (default), `bottom`
- `options.classname {String}` optional, a custom container class for all items

Method: `component.hide()`

__HTML rendering__:

```js
var opt = {};
opt.html = 'Your HTML code';
```

__RAW element rendering__:

```js
var opt = {};
opt.html = YOUR_DOM_ELEMENT;
// IMPORTANT: if the FloatingBox will be closed, then the element will be moved to the previous parent.
```

__Importing content__:

```js
var opt = {};
opt.import = '/url/part.html';
// IMPORTANT: the content will be cached for the future usage
```

### Good to know

- elements with `selectable` class will be selectable

__Methods__:

- `component.up()` selects item above
- `component.down()` selects item below
- `component.select([el])` selects item

You can combine methods with `j-Shortcuts` component.

Use it with `<ui-component name="floatingpanel">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="exec"></ui-component>
<ui-component name="floatingpanel"></ui-component>

<span class="exec" data-exec="showpanel" style="color:#2A6CEC;cursor:pointer;text-decoration:underline" class="block">Show panel</span>

<script>

	function showpanel(el) {
		var opt = {};
		opt.element = el;
		opt.html = '<div class="padding">Custom content</div>';
		SETTER('floatingpanel/show', opt);
	}

</script>
```
