lure-2026/public/csspageweaver/plugins/moveElems/README.md
2026-01-10 18:33:22 +01:00

82 lines
1.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: Move Elems
tags: stable, feedback-wanted
description: Moves elements within the DOM structure during rendering.
---
# Move Elems (paged.js)
This plugin moves elements within the DOM structure during rendering. Usefull with other script like [Full page](https://gitlab.com/csspageweaver/plugins/fullPage) or [Float page](https://gitlab.com/csspageweaver/plugins/floatPage).
This plugin moves elements relative to their sibling elements in the DOM — either forward or backward — based on the integer value you provide.
You need to use [csstree.js](https://github.com/csstree/csstree) in order to transform custom properties.
If you use CSS PageWeaver is inclued by default
## How to install
**With CSS Page Weaver**
Register the `moveElems` plugin in your `manifest.json`:
```json
[
"moveElems",
// other plugins
]
```
⚠️ Its recommended to load this plugin first to prevent any conflicts with other plugins.
**Without CSS PageWeaver**
Include both csstree and the fullPage script in your HTML `<head>`:
```html
<script src="js/csstree.min.js"></script>
<script type="module" src="path/to/fullPage/floatPage.js"></script>
```
Dont forget to update the path to the paged.esm.js module in the import statement before using the script.
```js
import { Handler } from '/path/to/paged.esm.js'
```
## How to use it
In your CSS, add the following custom property to the elements you want to move, using an ID or class:
```css
elem{
--x-move-elem: 2;
}
```
In this example, the element will be moved after its second next sibling.
You can also use negative values to move elements backward, e.g.:
```css
elem{
--x-move-elem: -3;
}
```
This would move the element before its third previous sibling.
## Credits
- [pagedjs.org](https://www.pagedjs.org/)
- [csstree.js](https://github.com/csstree/csstree)
MIT licence, Julie Blanc, 2025