-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Applelo/dev
Version 0.7.0
- Loading branch information
Showing
19 changed files
with
313 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Drag Demo | ||
|
||
<script setup> | ||
import './../../packages/core/dist/css/drag.css' | ||
import { Drag } from './../../packages/core' | ||
import { onMounted } from 'vue' | ||
|
||
onMounted(() => { | ||
const drag = new Drag('.c-drag') | ||
}) | ||
</script> | ||
<style> | ||
.c-drag { | ||
height: 250px; | ||
} | ||
|
||
.c-drag > div { | ||
width: 200%; | ||
} | ||
|
||
.c-drag p:first-child { | ||
width: 300px; | ||
} | ||
</style> | ||
<div style="margin-top: 2rem;"> | ||
<div class="c-drag"> | ||
<div> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Mollitia facere possimus impedit facilis culpa illo earum deserunt consequuntur minus. Ad et qui labore reprehenderit magnam exercitationem placeat magni nesciunt suscipit. | ||
</p> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Mollitia facere possimus impedit facilis culpa illo earum deserunt consequuntur minus. Ad et qui labore reprehenderit magnam exercitationem placeat magni nesciunt suscipit. | ||
</p> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Drag | ||
|
||
The drag component allows to create a draggable zone you can control with your mouse. | ||
|
||
```scss | ||
@import 'compotes/css/drag'; | ||
``` | ||
|
||
```js | ||
import { Drag } from 'compotes' | ||
|
||
const drag = new Drag('.c-drag') | ||
``` | ||
|
||
You need to have a width and/or height define on the component because it uses `overflow: auto;`. | ||
|
||
```html | ||
|
||
<div class="c-drag"> | ||
<!-- Your overflowing content --> | ||
</div> | ||
``` | ||
|
||
## Options | ||
|
||
You can access some data from the component. | ||
|
||
```js | ||
import { Drag } from 'compotes' | ||
|
||
const drag = new Drag('.c-drag', { | ||
init: true, // [!code focus:2] | ||
initEvents: true | ||
}) | ||
``` | ||
|
||
- `init` (boolean): Init the component on creation | ||
- `initEvents` (boolean): Init events on the component | ||
|
||
## Methods | ||
|
||
The drag component provides several methods to init and destroy the components. | ||
|
||
```js | ||
import { Drag } from 'compotes' | ||
|
||
const drag = new Drag('.c-drag', { | ||
init: false | ||
}) | ||
drag.init()// [!code focus] | ||
``` | ||
|
||
- `init()`: Init the component | ||
- `initEvents()`: Init component events | ||
- `destroyEvents()`: Destroy the component events | ||
- `destroy()`: Destroy the component | ||
|
||
## Data | ||
|
||
You can access data from the component like this: | ||
|
||
```js | ||
import { Drag } from 'compotes' | ||
|
||
const drag = new Drag('.c-drag') | ||
console.log(drag.isDraggable)// [!code focus] | ||
``` | ||
|
||
- `options` (options object): Get options used to init the component | ||
- `isDraggable` (boolean): Tell if the component is draggable or not | ||
- `isDragging` (boolean): Tell if the component is currently dragging or not | ||
|
||
## Events | ||
|
||
You can listen to emitted events directly on the drag element like this: | ||
|
||
```js | ||
import { Drag } from 'compotes' | ||
|
||
const drag = new Drag('.c-drag') | ||
drag.addEventListener('c.drag.init', (e) => { // [!code focus:3] | ||
console.log(e.detail)// drag object | ||
}) | ||
``` | ||
|
||
- `c.drag.init`: On component init | ||
- `c.drag.start`: On component drag start | ||
- `c.drag.end`: On component drag end | ||
- `c.drag.destroy`: On component destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.c-drag { | ||
overflow: auto; | ||
} | ||
|
||
.c-drag--draggable { | ||
cursor: grab; | ||
} | ||
|
||
.c-drag--dragging { | ||
cursor: grabbing; | ||
} | ||
|
||
.c-drag--dragging * { | ||
user-select: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.