@cocreate/position 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +3 -0
- package/.github/workflows/automated.yml +83 -0
- package/.github/workflows/manual.yml +44 -0
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +97 -0
- package/CoCreate.config.js +43 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/demo/index.html +51 -0
- package/docs/index.html +176 -0
- package/package.json +67 -0
- package/release.config.js +22 -0
- package/src/index.css +95 -0
- package/src/index.js +30 -0
- package/src/position.js +359 -0
- package/webpack.config.js +85 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Automated
|
|
2
|
+
"on":
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
jobs:
|
|
7
|
+
about:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Checkout
|
|
11
|
+
uses: actions/checkout@v2
|
|
12
|
+
- name: Jaid/action-sync-node-meta
|
|
13
|
+
uses: jaid/action-sync-node-meta@v1.4.0
|
|
14
|
+
with:
|
|
15
|
+
direction: overwrite-github
|
|
16
|
+
githubToken: "${{ secrets.GITHUB }}"
|
|
17
|
+
release:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v2
|
|
22
|
+
- name: Semantic Release
|
|
23
|
+
uses: cycjimmy/semantic-release-action@v2
|
|
24
|
+
id: semantic
|
|
25
|
+
with:
|
|
26
|
+
extra_plugins: |
|
|
27
|
+
@semantic-release/changelog
|
|
28
|
+
@semantic-release/git
|
|
29
|
+
@semantic-release/github
|
|
30
|
+
env:
|
|
31
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
32
|
+
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
33
|
+
outputs:
|
|
34
|
+
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
35
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
36
|
+
cdn:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: release
|
|
39
|
+
if: needs.release.outputs.new_release_published == 'true'
|
|
40
|
+
env:
|
|
41
|
+
VERSION: "${{ needs.release.outputs.new_release_version }}"
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout
|
|
44
|
+
uses: actions/checkout@v2
|
|
45
|
+
- name: setup nodejs
|
|
46
|
+
uses: actions/setup-node@v2
|
|
47
|
+
with:
|
|
48
|
+
node-version: 14.15.4
|
|
49
|
+
- name: yarn install
|
|
50
|
+
run: >
|
|
51
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >
|
|
52
|
+
.npmrc
|
|
53
|
+
|
|
54
|
+
yarn install
|
|
55
|
+
- name: yarn build
|
|
56
|
+
run: yarn build
|
|
57
|
+
- name: upload bundle as version
|
|
58
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
59
|
+
with:
|
|
60
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
61
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
62
|
+
bucket: testcrudbucket
|
|
63
|
+
source: ./dist
|
|
64
|
+
destination: "/position/${{env.VERSION}}"
|
|
65
|
+
acl: public-read
|
|
66
|
+
- name: upload bundle as latest
|
|
67
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
68
|
+
with:
|
|
69
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
70
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
71
|
+
bucket: testcrudbucket
|
|
72
|
+
source: ./dist
|
|
73
|
+
destination: /position/latest
|
|
74
|
+
acl: public-read
|
|
75
|
+
invalidations: true
|
|
76
|
+
docs:
|
|
77
|
+
runs-on: ubuntu-latest
|
|
78
|
+
steps:
|
|
79
|
+
- name: Checkout
|
|
80
|
+
uses: actions/checkout@v2
|
|
81
|
+
|
|
82
|
+
- name: update documentation
|
|
83
|
+
uses: CoCreate-app/CoCreate-docs@master
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Manual Workflow
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
invalidations:
|
|
6
|
+
description: |
|
|
7
|
+
If set to 'true', invalidates previous upload.
|
|
8
|
+
default: "true"
|
|
9
|
+
required: true
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
cdn:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
env:
|
|
15
|
+
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
|
16
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
17
|
+
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v2
|
|
22
|
+
- name: setup nodejs
|
|
23
|
+
uses: actions/setup-node@v2
|
|
24
|
+
with:
|
|
25
|
+
node-version: 14.15.4
|
|
26
|
+
- name: yarn install
|
|
27
|
+
run: >
|
|
28
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >
|
|
29
|
+
.npmrc
|
|
30
|
+
|
|
31
|
+
yarn install
|
|
32
|
+
- name: yarn build
|
|
33
|
+
run: yarn build
|
|
34
|
+
- name: upload latest bundle
|
|
35
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
36
|
+
with:
|
|
37
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
38
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
39
|
+
distributionId: "${{ secrets.DISTRIBUTION_ID }}"
|
|
40
|
+
bucket: testcrudbucket
|
|
41
|
+
source: ./dist
|
|
42
|
+
destination: /position/latest
|
|
43
|
+
acl: public-read
|
|
44
|
+
invalidations: ${{ github.event.inputs.invalidations }}
|
package/CHANGELOG.md
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Contributing to CoCreate-position
|
|
2
|
+
|
|
3
|
+
This project is work of [many contributors](https://github.com/CoCreate-app/CoCreate-position/graphs/contributors).
|
|
4
|
+
You're encouraged to submit [pull requests](https://github.com/CoCreate-app/CoCreate-position/pulls),
|
|
5
|
+
[propose features and discuss issues](https://github.com/CoCreate-app/CoCreate-position/issues).
|
|
6
|
+
|
|
7
|
+
In the examples below, substitute your Github username for `contributor` in URLs.
|
|
8
|
+
|
|
9
|
+
## Fork the Project
|
|
10
|
+
|
|
11
|
+
Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-position) and check out your copy.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
git modal https://github.com/contributor/CoCreate-position.git
|
|
15
|
+
cd CoCreate-position
|
|
16
|
+
git remote add upstream https://github.com/CoCreate-app/CoCreate-position.git
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Create a Topic Branch
|
|
20
|
+
|
|
21
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix on dev branch.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
git checkout dev
|
|
25
|
+
git pull upstream dev
|
|
26
|
+
git checkout -b my-feature-branch
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Write Tests
|
|
30
|
+
|
|
31
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
|
32
|
+
|
|
33
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
|
34
|
+
|
|
35
|
+
## Write Code
|
|
36
|
+
|
|
37
|
+
Implement your feature or bug fix.
|
|
38
|
+
|
|
39
|
+
## Write Documentation
|
|
40
|
+
|
|
41
|
+
Document any external behavior in the [README](README.md).
|
|
42
|
+
|
|
43
|
+
## Commit Changes
|
|
44
|
+
|
|
45
|
+
Make sure git knows your name and email address:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
git config --global user.name "Your Name"
|
|
49
|
+
git config --global user.email "contributor@example.com"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
We use [semantic-release](https://github.com/semantic-release/semantic-release) as process to generate changelog
|
|
53
|
+
and to release. Write meaningful commits according to
|
|
54
|
+
[Commit Message Formats](https://github.com/semantic-release/semantic-release#commit-message-format) is important.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
git add ...
|
|
58
|
+
git commit -am "commit-type(optional topic): a meaningful message"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Here is an example of the release type that should be done based on a [semantic-release](https://github.com/semantic-release/semantic-release):
|
|
62
|
+
|
|
63
|
+
| Commit message | Release type |
|
|
64
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- |
|
|
65
|
+
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
|
|
66
|
+
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
|
|
67
|
+
| `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Push
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
git push origin my-feature-branch
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Make a Pull Request
|
|
77
|
+
|
|
78
|
+
Go to [https://github.com/CoCreate-app/CoCreate-position](https://github.com/CoCreate-app/CoCreate-position) and select your feature branch.
|
|
79
|
+
Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
80
|
+
|
|
81
|
+
## Rebase
|
|
82
|
+
|
|
83
|
+
If you've been working on a change for a while, rebase with upstream/dev.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
git fetch upstream
|
|
87
|
+
git rebase upstream/dev
|
|
88
|
+
git push origin my-feature-branch -f
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Be Patient
|
|
92
|
+
|
|
93
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there!
|
|
94
|
+
|
|
95
|
+
## Thank You
|
|
96
|
+
|
|
97
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"config": {
|
|
3
|
+
"apiKey": "2061acef-0451-4545-f754-60cf8160",
|
|
4
|
+
"organization_id": "5ff747727005da1c272740ab",
|
|
5
|
+
"host": "general.cocreate.app"
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
"sources": [{
|
|
9
|
+
"entry": "./docs/index.html",
|
|
10
|
+
"collection": "files",
|
|
11
|
+
"document_id": "60206d5b3c260207bf49cab4",
|
|
12
|
+
"key": "src",
|
|
13
|
+
"data":{
|
|
14
|
+
"name": "index.html",
|
|
15
|
+
"path": "/docs/modal/index.html",
|
|
16
|
+
"domains": [
|
|
17
|
+
"*",
|
|
18
|
+
"general.cocreate.app"
|
|
19
|
+
],
|
|
20
|
+
"directory": "/docs/modal",
|
|
21
|
+
"content-type": "text/html",
|
|
22
|
+
"public": "true",
|
|
23
|
+
"website_id": "5ffbceb7f11d2d00103c4535"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
"extract": {
|
|
29
|
+
"directory": "./src/",
|
|
30
|
+
"extensions": [
|
|
31
|
+
"js",
|
|
32
|
+
"css",
|
|
33
|
+
"html"
|
|
34
|
+
],
|
|
35
|
+
"ignores": [
|
|
36
|
+
"node_modules",
|
|
37
|
+
"vendor",
|
|
38
|
+
"bower_components",
|
|
39
|
+
"archive"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 CoCreate LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# CoCreate-position
|
|
2
|
+
|
|
3
|
+
A draggable, movable and resizable modal. customizable via attributes, great for popups, alerts, multitasking and displaying multiple views. Take it for a spin in our [playground!](https://cocreate.app/docs/modal)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## [Docs & Demo](https://cocreate.app/docs/modal)
|
|
15
|
+
|
|
16
|
+
For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/modal)
|
|
17
|
+
|
|
18
|
+
## CDN
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://cdn.cocreate.app/modal/latest/CoCreate-position.min.js"></script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script src="https://cdn.cocreate.app/modal/latest/CoCreate-position.min.css"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## NPM
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
$ npm i @cocreate/modal
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## yarn
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
$ yarn install @cocreate/modal
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# Table of Contents
|
|
41
|
+
|
|
42
|
+
- [Table of Contents](#table-of-contents)
|
|
43
|
+
- [Announcements](#announcements)
|
|
44
|
+
- [Roadmap](#roadmap)
|
|
45
|
+
- [How to Contribute](#how-to-contribute)
|
|
46
|
+
- [About](#about)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
|
|
49
|
+
<a name="announcements"></a>
|
|
50
|
+
|
|
51
|
+
# Announcements
|
|
52
|
+
|
|
53
|
+
All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreate-app/CoCreate-position/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreate-app/CoCreate-position/releases). You may also subscribe to email for releases and breaking changes.
|
|
54
|
+
|
|
55
|
+
<a name="roadmap"></a>
|
|
56
|
+
|
|
57
|
+
# Roadmap
|
|
58
|
+
|
|
59
|
+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreate-app/CoCreate-position/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-position/pulls). We would love to hear your feedback.
|
|
60
|
+
|
|
61
|
+
<a name="about"></a>
|
|
62
|
+
|
|
63
|
+
# About
|
|
64
|
+
|
|
65
|
+
CoCreate-position is guided and supported by the CoCreate Developer Experience Team.
|
|
66
|
+
|
|
67
|
+
Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) in case of any queries.
|
|
68
|
+
|
|
69
|
+
CoCreate-position is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
|
70
|
+
|
|
71
|
+
<a name="contribute"></a>
|
|
72
|
+
|
|
73
|
+
# How to Contribute
|
|
74
|
+
|
|
75
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-position/blob/master/CONTRIBUTING.md) guide for details.
|
|
76
|
+
|
|
77
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-position/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-position/pulls) or merely upvote or comment on existing issues or pull requests.
|
|
78
|
+
|
|
79
|
+
We appreciate your continued support, thank you!
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
<a name="license"></a>
|
|
83
|
+
# License
|
|
84
|
+
|
|
85
|
+
[The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-position/blob/master/LICENSE)
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>Position | CoCreateJS</title>
|
|
6
|
+
<link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
height: 100vh;
|
|
10
|
+
margin: 0px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[drag-area] {
|
|
14
|
+
top: 0px;
|
|
15
|
+
left: 0px;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 50px;
|
|
18
|
+
padding: 0.5em;
|
|
19
|
+
position: absolute;
|
|
20
|
+
background: gainsboro;
|
|
21
|
+
cursor: move;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<body>
|
|
28
|
+
|
|
29
|
+
<!--<div class="">-->
|
|
30
|
+
<div class="position:fixed height:300px width:300px background:whitesmoke" positionable>
|
|
31
|
+
<div class="height:40px" drag-area></div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div class="position:fixed height:300px width:300px background:brown" positionable>
|
|
35
|
+
<div class="height:40px" drag-area></div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<!-- <div class="resize resize3" resizable>
|
|
39
|
+
<div resize="left"></div>
|
|
40
|
+
<div resize="right"></div>
|
|
41
|
+
<div resize="top"></div>
|
|
42
|
+
<div resize="bottom"></div>
|
|
43
|
+
</div> -->
|
|
44
|
+
<!--</div>-->
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<script src="../dist/CoCreate-position.js"></script>
|
|
48
|
+
<script src="../../../CoCreateJS/dist/CoCreate.js" ></script>
|
|
49
|
+
</body>
|
|
50
|
+
|
|
51
|
+
</html>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<title>CoCreate-position Documentation | CoCreateJS</title>
|
|
9
|
+
<link rel="icon" type="image/png" sizes="32x32" href="https://cocreate.app/images/favicon.ico">
|
|
10
|
+
<meta name="description" content="A draggable, customizable Pop up that toggle hiddent content via attributes. Great for multitasking and showing multiple views." />
|
|
11
|
+
<meta name="keywords" content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
12
|
+
<meta name="robots" content="index,follow" />
|
|
13
|
+
<meta property="og:image" content="https://cdn.cocreate.app/docs/modal.png">
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
|
|
20
|
+
<nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd" name="src">
|
|
21
|
+
</nav>
|
|
22
|
+
<sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
|
|
23
|
+
<menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
|
|
24
|
+
<div resize="right"></div>
|
|
25
|
+
</sidenav>
|
|
26
|
+
<main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-position">
|
|
27
|
+
<div class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px">
|
|
28
|
+
<div class="display:flex align-items:center">
|
|
29
|
+
<h2>CoCreate-position</h2>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
|
|
32
|
+
<div class="display:flex align-items:center transition:0.3s padding-left:10px" share-network="true" share-text="A draggable, customizable Pop up that toggle hiddent content via attributes. Great for multitasking and showing multiple views."
|
|
33
|
+
share-title="CoCreate-position" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/modal.png" hover="display:block!important" hover-target=".social-networks">
|
|
34
|
+
<div class="display:none social-networks">
|
|
35
|
+
<a class="margin-right:15px" share-network='twitter' title="Share on twitter"><i class="fab fa-twitter"></i></a>
|
|
36
|
+
<a class="margin-right:15px" share-network='facebook' title="Share on Facebook"><i class="fab fa-facebook"></i></a>
|
|
37
|
+
<a class="margin-right:15px" share-network='instagram' title="Share on instagram"><i class="fab fa-instagram"></i></a>
|
|
38
|
+
</div>
|
|
39
|
+
<a class="margin-right:15px" share-network='share' title="Share on share"><i class="fas fa-share-alt"></i></a>
|
|
40
|
+
</div>
|
|
41
|
+
<a href="https://github.com/CoCreate-app/CoCreate-position" target="_blank" class="margin-right:15px"><i class="fab fa-github"></i></a>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<h1 class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">A draggable, customizable Pop up that toggle hiddent content via attributes. Great for multitasking and showing multiple views.
|
|
45
|
+
</h1>
|
|
46
|
+
<div id="xxxxx-section" class="display:flex flex-wrap:wrap">
|
|
47
|
+
<div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
|
|
48
|
+
|
|
49
|
+
<div id="modal-usage" class="margin-top:80px border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#modal-usage-section">
|
|
50
|
+
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target='[href="#modal-usage"]'>
|
|
51
|
+
<h2 class="padding:5px_0px">Usage</h2>
|
|
52
|
+
<a class="margin-left:10px display:none" href="#modal-usage"><i class="fas fa-link"></i></a>
|
|
53
|
+
</span>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="">
|
|
56
|
+
<p class="padding-top:15px">CoCreate-position uses <a> tag.</p>
|
|
57
|
+
<p class="padding-top:15px">When you click <a> tag, modal comes to the surface.</p>
|
|
58
|
+
|
|
59
|
+
<div class="flex-grow:1 min-width:300px width:100%">
|
|
60
|
+
<pre>
|
|
61
|
+
<code class="language-html">
|
|
62
|
+
<button>
|
|
63
|
+
<a target="modal" href="https://server.cocreate.app/CoCreate-adminUI/module_datatable.html"
|
|
64
|
+
modal-ajax="false"
|
|
65
|
+
modal-width="520px"
|
|
66
|
+
modal-height="100%"
|
|
67
|
+
modal-color="#229954"
|
|
68
|
+
modal-header="false"
|
|
69
|
+
modal-x="0px"
|
|
70
|
+
modal-y="0px"
|
|
71
|
+
data-open_in="page">
|
|
72
|
+
Show Modal On Page
|
|
73
|
+
</a>
|
|
74
|
+
</button>
|
|
75
|
+
</code>
|
|
76
|
+
</pre>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<div id="modal-attributes" class="margin-top:80px border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#modal-attributes-section">
|
|
80
|
+
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target='[href="#modal-attributes"]'>
|
|
81
|
+
<h2 class="padding:5px_0px">Attributes</h2>
|
|
82
|
+
<a class="margin-left:10px display:none" href="#modal-attributes"><i class="fas fa-link"></i></a>
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
<ul class="list-style-type:none ">
|
|
86
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
87
|
+
<h4><span>target</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge danger">required</span></h4>
|
|
88
|
+
<p>Target must be "modal".</p>
|
|
89
|
+
</li>
|
|
90
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
91
|
+
<h4><span>href</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge danger">required</span></h4>
|
|
92
|
+
<p>Href attribute indicates html file to set in modal.</p>
|
|
93
|
+
</li>
|
|
94
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
95
|
+
<h4><span>modal-ajax</span> <span class="cocreate-badge success">boolean</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
96
|
+
<p>Attribute whether to use ajax or not.</p>
|
|
97
|
+
</li>
|
|
98
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
99
|
+
<h4><span>modal-width</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
100
|
+
<p>Width of modal. Unit can be pixel or percent.</p>
|
|
101
|
+
</li>
|
|
102
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
103
|
+
<h4><span>modal-height</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
104
|
+
<p>Height of modal. Unit can be pixel or percent.</p>
|
|
105
|
+
</li>
|
|
106
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
107
|
+
<h4><span>modal-color</span> <span class="cocreate-badge success">color</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
108
|
+
<p>Color of modal border.</p>
|
|
109
|
+
</li>
|
|
110
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
111
|
+
<h4><span>modal-header</span> <span class="cocreate-badge success">boolean</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
112
|
+
<p>Attribute whether to show header or not.</p>
|
|
113
|
+
</li>
|
|
114
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
115
|
+
<h4><span>modal-x</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
116
|
+
<p>Position X of modal.</p>
|
|
117
|
+
</li>
|
|
118
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
119
|
+
<h4><span>modal-y</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
120
|
+
<p>Position Y of modal.</p>
|
|
121
|
+
</li>
|
|
122
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
123
|
+
<h4><span>open_in</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
124
|
+
<p>Attribute where to show modal in. "page" for current page. "parent" for parent page. "root" for root page.</p>
|
|
125
|
+
</li>
|
|
126
|
+
</ul>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
|
|
130
|
+
<!-- SandBox -->
|
|
131
|
+
<div id="modal-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#modal-demo-section">
|
|
132
|
+
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target='[href="#modal-demo"]'>
|
|
133
|
+
<h2 class="padding:5px_0px">Demo</h2>
|
|
134
|
+
<a class="margin-left:10px display:none" href="#modal-demo"><i class="fas fa-link"></i></a>
|
|
135
|
+
</span>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
138
|
+
<!-- SandBox -->
|
|
139
|
+
<div class="container svColumn overflow:hidden card position:relative border-radius:2px width:auto height:100%" id="sandbox">
|
|
140
|
+
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
141
|
+
<a class="margin-right:10px" id="code" show="#preview" hide="#code, #view"><i class="far fa-eye"></i></a>
|
|
142
|
+
<a class="margin-right:10px" id="preview" show="#code, #view" hide="#preview" hidden><i class="fas fa-code"></i></a>
|
|
143
|
+
<a class="margin-right:5px" fullscreen target="#playground"><i class="fas fa-expand"></i></a>
|
|
144
|
+
</div>
|
|
145
|
+
<div class="svRow">
|
|
146
|
+
|
|
147
|
+
<div class="svColumn">
|
|
148
|
+
|
|
149
|
+
<div class="svPanel" id="view">
|
|
150
|
+
<textarea collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% border:none resize:none padding:5px"></textarea>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="svSplitter svHorizontal"> </div>
|
|
153
|
+
|
|
154
|
+
<div class="svPanel">
|
|
155
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
<!-- End SandBox -->
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
</div>
|
|
166
|
+
<button href="https://github.com/CoCreate-app/CoCreate-position/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..." target="_blank" class="position:fixed bottom:15px right:15px padding:15px background:dodgerblue grow-hover border-radius:50%">
|
|
167
|
+
<i class="fas fa-pencil-alt"></i>
|
|
168
|
+
</button>
|
|
169
|
+
</main>
|
|
170
|
+
|
|
171
|
+
<script src="./apikey.js"></script>
|
|
172
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
173
|
+
|
|
174
|
+
</body>
|
|
175
|
+
|
|
176
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cocreate/position",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Make any element draggable and movable. Customizable via attributes, great for popups, alerts, multitasking and displaying multiple views.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"position",
|
|
7
|
+
"cocreate",
|
|
8
|
+
"low-code-framework",
|
|
9
|
+
"no-code-framework",
|
|
10
|
+
"cocreatejs",
|
|
11
|
+
"cocreatejs-component",
|
|
12
|
+
"cocreate-framework",
|
|
13
|
+
"no-code",
|
|
14
|
+
"low-code",
|
|
15
|
+
"collaborative-framework",
|
|
16
|
+
"realtime",
|
|
17
|
+
"realtime-framework",
|
|
18
|
+
"collaboration",
|
|
19
|
+
"shared-editing",
|
|
20
|
+
"html5-framework",
|
|
21
|
+
"javascript-framework"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "npx webpack --config webpack.config.js",
|
|
28
|
+
"build": "NODE_ENV=production npx webpack --config webpack.config.js",
|
|
29
|
+
"dev": "npx webpack --config webpack.config.js --watch",
|
|
30
|
+
"docs": "node ./node_modules/@cocreate/docs/src/index.js",
|
|
31
|
+
"hosting": "node ./node_modules/@cocreate/hosting/src/index.js"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/CoCreate-app/CoCreate-position.git"
|
|
36
|
+
},
|
|
37
|
+
"author": "CoCreate LLC",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/CoCreate-app/CoCreate-position/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://cocreate.app/docs/position",
|
|
43
|
+
"funding": {
|
|
44
|
+
"type": "GitHub Sponsors ❤",
|
|
45
|
+
"url": "https://github.com/sponsors/CoCreate-app"
|
|
46
|
+
},
|
|
47
|
+
"main": "./src/index.js",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/core": "^7.9.6",
|
|
50
|
+
"@babel/preset-env": "^7.9.6",
|
|
51
|
+
"babel-loader": "^8.1.0",
|
|
52
|
+
"clean-webpack-plugin": "^3.0.0",
|
|
53
|
+
"file-loader": "^6.2.0",
|
|
54
|
+
"html-webpack-plugin": "^4.5.0",
|
|
55
|
+
"mini-css-extract-plugin": "^1.5.0",
|
|
56
|
+
"style-loader": "^2.0.0",
|
|
57
|
+
"terser-webpack-plugin": "^5.1.1",
|
|
58
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
59
|
+
"webpack": "^5.24.4",
|
|
60
|
+
"webpack-cli": "^4.5.0",
|
|
61
|
+
"webpack-log": "^3.0.1"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@cocreate/docs": "^1.3.1",
|
|
65
|
+
"@cocreate/observer": "^1.5.1"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dryRun: false,
|
|
3
|
+
branches: ["master"],
|
|
4
|
+
plugins: [
|
|
5
|
+
"@semantic-release/commit-analyzer",
|
|
6
|
+
"@semantic-release/release-notes-generator",
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/changelog",
|
|
9
|
+
{
|
|
10
|
+
changelogFile: "CHANGELOG.md",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
"@semantic-release/npm",
|
|
14
|
+
"@semantic-release/github",
|
|
15
|
+
[
|
|
16
|
+
"@semantic-release/git",
|
|
17
|
+
{
|
|
18
|
+
assets: ["CHANGELOG.md", "package.json"],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
],
|
|
22
|
+
};
|
package/src/index.css
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#modal-viewport {
|
|
2
|
+
/*position: relative;*/
|
|
3
|
+
z-index: 8;
|
|
4
|
+
height: -moz-available;
|
|
5
|
+
height: calc(100vh - 50px);
|
|
6
|
+
height: -webkit-fill-available;
|
|
7
|
+
height: fill-available;
|
|
8
|
+
width: -moz-available;
|
|
9
|
+
width: -webkit-fill-available;
|
|
10
|
+
width: fill-available;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
top: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.hide-nav + #modal-viewport{
|
|
16
|
+
margin-top:0px;
|
|
17
|
+
height: 100vh;
|
|
18
|
+
max-height: -moz-available;
|
|
19
|
+
max-height: -webkit-fill-available;
|
|
20
|
+
max-height: fill-available;
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.modal.selected {
|
|
25
|
+
z-index: 10;
|
|
26
|
+
border-color: purple;
|
|
27
|
+
pointer-events: auto;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** modal title **/
|
|
32
|
+
.modal-ghost {
|
|
33
|
+
display: none;
|
|
34
|
+
background: #999;
|
|
35
|
+
opacity: 0;
|
|
36
|
+
/*pointer-events: none;*/
|
|
37
|
+
/* width: 300px;*/
|
|
38
|
+
/*height: 200px;*/
|
|
39
|
+
top: 0px;
|
|
40
|
+
left: 0px;
|
|
41
|
+
z-index: 20;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
position: absolute;
|
|
45
|
+
margin: 0;
|
|
46
|
+
padding: 0;
|
|
47
|
+
|
|
48
|
+
-webkit-transition: all 0.25s ease-in-out;
|
|
49
|
+
-moz-transition: all 0.25s ease-in-out;
|
|
50
|
+
-ms-transition: all 0.25s ease-in-out;
|
|
51
|
+
-o-transition: all 0.25s ease-in-out;
|
|
52
|
+
transition: all 0.25s ease-in-out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
.modal-drag-area {
|
|
57
|
+
position: absolute;
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
min-height: 10px;
|
|
60
|
+
z-index: 10;
|
|
61
|
+
left: 0;
|
|
62
|
+
top: 0;
|
|
63
|
+
right: 0;
|
|
64
|
+
height: 20px;
|
|
65
|
+
cursor: move;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.modal-parked {
|
|
69
|
+
width: 50px !important;
|
|
70
|
+
height: 50px !important;
|
|
71
|
+
border-radius: 50px;
|
|
72
|
+
z-index: 100 !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.modal-parked * {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.parked-closeBtn {
|
|
80
|
+
width: 20px;
|
|
81
|
+
height: 20px;
|
|
82
|
+
border-radius: 20px;
|
|
83
|
+
position: absolute;
|
|
84
|
+
background-color: #ddd;
|
|
85
|
+
right: -3px;
|
|
86
|
+
top: -3px;
|
|
87
|
+
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
.modal-parked:hover > .parked-closeBtn{
|
|
91
|
+
display: flex!important;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import observer from '@cocreate/observer';
|
|
2
|
+
import position from './position'
|
|
3
|
+
import './index.css'
|
|
4
|
+
|
|
5
|
+
function init(){
|
|
6
|
+
let elements = document.querySelectorAll('[moveable], [positionable]');
|
|
7
|
+
initElements(elements)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function initElements(elements) {
|
|
11
|
+
for (let element of elements)
|
|
12
|
+
initElement(element)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function initElement(element){
|
|
16
|
+
new position(element, element.parentElement);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
observer.init({
|
|
20
|
+
name: "positionAddedNodes",
|
|
21
|
+
observe: ['addedNodes'],
|
|
22
|
+
target: '[moveable], [positionable]',
|
|
23
|
+
callback: mutation => {
|
|
24
|
+
initElement(mutation.target);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
init()
|
|
29
|
+
|
|
30
|
+
export default position;
|
package/src/position.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
function position(el, container) {
|
|
2
|
+
if (!(el && el.nodeType && el.nodeType === 1)) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** define constant **/
|
|
7
|
+
this.dragAreaHeight = 50;
|
|
8
|
+
this.MARGIN = 5;
|
|
9
|
+
this.FULLSCREEN_MARGIN = -60;
|
|
10
|
+
this.NO_SNAP = -100;
|
|
11
|
+
this.SNAP_MARGIN = -10;
|
|
12
|
+
this.SELECT_ZINDEX = 10;
|
|
13
|
+
this.UNSELECT_ZINDEX = 2;
|
|
14
|
+
|
|
15
|
+
this.RIGHT_SCROL = 5;
|
|
16
|
+
|
|
17
|
+
this.container = container;
|
|
18
|
+
this.el = el;
|
|
19
|
+
this.boundStatus = {};
|
|
20
|
+
|
|
21
|
+
this.selectedElement;
|
|
22
|
+
/**
|
|
23
|
+
* x: mouse x in element
|
|
24
|
+
* y: mouse y in element
|
|
25
|
+
* cx: x in document
|
|
26
|
+
* cy: y in document
|
|
27
|
+
* */
|
|
28
|
+
this.point = {};
|
|
29
|
+
this.rect = {};
|
|
30
|
+
this.clickedInfo = null;
|
|
31
|
+
this.preSnapped = null;
|
|
32
|
+
this.isSnap = false;
|
|
33
|
+
this.isHeader = true;
|
|
34
|
+
|
|
35
|
+
this._createGhost(this.container.getAttribute("data-ghost-class"));
|
|
36
|
+
this._initEvent();
|
|
37
|
+
this._selectElement()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
position.prototype = {
|
|
41
|
+
constructor: position,
|
|
42
|
+
|
|
43
|
+
_initEvent : function() {
|
|
44
|
+
let self = this;
|
|
45
|
+
this.iframe = this.el.querySelector('iframe')
|
|
46
|
+
if (this.iframe) {
|
|
47
|
+
this.iframe.addEventListener('load', function() {
|
|
48
|
+
const iframeContent = self.iframe.contentDocument;
|
|
49
|
+
iframeContent.addEventListener('click', function() {
|
|
50
|
+
self.createEvent('elementSelected');
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.el.addEventListener("click", function(e) {
|
|
56
|
+
self.createEvent('elementSelected');
|
|
57
|
+
}, true)
|
|
58
|
+
|
|
59
|
+
this.el.addEventListener('touchstart', function(e) {
|
|
60
|
+
self.createEvent('elementSelected');
|
|
61
|
+
self._onDown(e.touches[0]);
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
this.el.addEventListener('mousedown', function(e) {
|
|
65
|
+
self.createEvent('elementSelected');
|
|
66
|
+
self._onDown(e);
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// events from container
|
|
70
|
+
this.el.addEventListener('mousemove', function(e) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
self._onMove(e);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
this.el.addEventListener('mouseup', function(e) {
|
|
76
|
+
self._onUp(e);
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
}, true);
|
|
79
|
+
|
|
80
|
+
this.el.addEventListener('touchmove', function(e) {
|
|
81
|
+
self._onMove(e.touches[0]);
|
|
82
|
+
}, { passive: false });
|
|
83
|
+
|
|
84
|
+
this.el.addEventListener('touchend', function(e) {
|
|
85
|
+
self._onUp(e.touches[0]);
|
|
86
|
+
}, { passive: false });
|
|
87
|
+
|
|
88
|
+
this.el.addEventListener('elementSelected', function(e) {
|
|
89
|
+
self._selectElement(e.detail.element);
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
_onMove : function(e) {
|
|
95
|
+
this.__getBoundStatus(e)
|
|
96
|
+
this.__animate();
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
_onDown : function(e) {
|
|
100
|
+
this.__getBoundStatus(e);
|
|
101
|
+
|
|
102
|
+
this.clickedInfo = {
|
|
103
|
+
x: this.point.x,
|
|
104
|
+
y: this.point.y,
|
|
105
|
+
cx: this.point.cx,
|
|
106
|
+
cy: this.point.cy,
|
|
107
|
+
w: this.rect.width,
|
|
108
|
+
h: this.rect.height,
|
|
109
|
+
isMoving: this._isMovable(),
|
|
110
|
+
boundStatus : this.boundStatus,
|
|
111
|
+
isChangeStart: true
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
_onUp: function(e) {
|
|
116
|
+
if (e) {
|
|
117
|
+
this.__getBoundStatus(e);
|
|
118
|
+
}
|
|
119
|
+
if (!this.clickedInfo) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (this.clickedInfo.isMoving && !this.isParked) {
|
|
123
|
+
let p_w = this.el.parentNode.offsetWidth, p_h = this.el.parentNode.offsetHeight;
|
|
124
|
+
let snap_info = null;
|
|
125
|
+
|
|
126
|
+
if (this.__between(this.rect.top, this.NO_SNAP, this.FULLSCREEN_MARGIN) ||
|
|
127
|
+
this.__between(this.rect.left, this.NO_SNAP, this.FULLSCREEN_MARGIN) ||
|
|
128
|
+
this.__between(p_w - this.rect.right, this.NO_SNAP, this.FULLSCREEN_MARGIN) ||
|
|
129
|
+
this.__between(p_h - this.rect.bottom, this.NO_SNAP, this.FULLSCREEN_MARGIN)) {
|
|
130
|
+
snap_info = {x: 0, y: 0, w:'100%', h:'100%'}
|
|
131
|
+
} else if (this.__between(this.rect.top, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
132
|
+
snap_info = {x: 0, y: 0, w:'100%', h:'50%'}
|
|
133
|
+
} else if (this.__between(this.rect.left, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
134
|
+
snap_info = {x: 0, y: 0, w:'50%', h:'100%'}
|
|
135
|
+
} else if (this.__between(p_w - this.rect.right, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
136
|
+
snap_info = {x: '50%', y: 0, w: '50%', h:'100%'}
|
|
137
|
+
} else if (this.__between(p_h - this.rect.bottom, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
138
|
+
snap_info = {x: 0, y: '50%', w: '100%', h: '50%'}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (snap_info && !this.isSnap) {
|
|
142
|
+
this.__setBound(this.el, snap_info.x, snap_info.y, snap_info.w, snap_info.h);
|
|
143
|
+
this.preSnapped = {x: this.rect.x, y: this.rect.y, width: this.rect.width, height: this.rect.height};
|
|
144
|
+
this.isSnap = true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var ghost_info = {
|
|
148
|
+
x: this.rect.x,
|
|
149
|
+
y: this.rect.y,
|
|
150
|
+
w: this.rect.width,
|
|
151
|
+
h: this.rect.height
|
|
152
|
+
}
|
|
153
|
+
// this.el.parentNode.dispatchEvent(new CustomEvent("cocreate-modalghost", {detail: ghost_info}));
|
|
154
|
+
this._ghostProcess(ghost_info)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (this.clickedInfo.isMoving) {
|
|
158
|
+
this.createEvent('element-moveend');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
this.clickedInfo = null;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
__setBound : function(el, x, y, w, h) {
|
|
166
|
+
el.style.left = x;
|
|
167
|
+
el.style.top = y;
|
|
168
|
+
el.style.width = w;
|
|
169
|
+
el.style.height = h;
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
__setRectInfo: function() {
|
|
173
|
+
let bound = this.el.getBoundingClientRect();
|
|
174
|
+
let parentRect = this.el.parentNode.getBoundingClientRect();
|
|
175
|
+
this.rect = {};
|
|
176
|
+
this.rect.x = bound.x - parentRect.x;
|
|
177
|
+
this.rect.y = bound.y - parentRect.y;
|
|
178
|
+
this.rect.width = bound.width;
|
|
179
|
+
this.rect.height = bound.height;
|
|
180
|
+
this.rect.top = bound.top - parentRect.top;
|
|
181
|
+
this.rect.bottom = bound.bottom - parentRect.top;
|
|
182
|
+
this.rect.left = bound.left - parentRect.left;
|
|
183
|
+
this.rect.right = bound.right - parentRect.left;
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
__getBoundStatus : function(e) {
|
|
187
|
+
let bound = this.el.getBoundingClientRect();
|
|
188
|
+
let parentRect = this.el.parentNode.getBoundingClientRect();
|
|
189
|
+
let x = e.clientX - bound.left;// - parentRect.left;
|
|
190
|
+
let y = e.clientY - bound.top;// - parentRect.top;
|
|
191
|
+
|
|
192
|
+
this.__setRectInfo();
|
|
193
|
+
|
|
194
|
+
this.point.x = x;
|
|
195
|
+
this.point.y = y;
|
|
196
|
+
this.point.cx = e.clientX - parentRect.left;
|
|
197
|
+
this.point.cy = e.clientY - parentRect.top;
|
|
198
|
+
|
|
199
|
+
this.boundStatus = {
|
|
200
|
+
isTop : y < this.MARGIN && y > -this.MARGIN,
|
|
201
|
+
isLeft : x < this.MARGIN && x > -this.MARGIN,
|
|
202
|
+
isRight : x >= bound.width - this.RIGHT_SCROL && x <= bound.width + this.MARGIN + (this.MARGIN - this.RIGHT_SCROL),
|
|
203
|
+
isBottom: y >= bound.height - this.MARGIN && y <= bound.height + this.MARGIN
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return this.boundStatus;
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
__between: function(x, min, max) {
|
|
210
|
+
return x >= min && x <= max;
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
__animate : function() {
|
|
214
|
+
let c_info = this.clickedInfo;
|
|
215
|
+
|
|
216
|
+
var eventName = null;
|
|
217
|
+
|
|
218
|
+
if (c_info && c_info.isMoving) {
|
|
219
|
+
/**
|
|
220
|
+
* Ghost Process
|
|
221
|
+
**/
|
|
222
|
+
|
|
223
|
+
let p_w = this.el.parentNode.offsetWidth, p_h = this.el.parentNode.offsetHeight;
|
|
224
|
+
let ghost_info = null;
|
|
225
|
+
|
|
226
|
+
if (this.__between(this.rect.top, this.NO_SNAP, this.FULLSCREEN_MARGIN) ||
|
|
227
|
+
this.__between(this.rect.left, this.NO_SNAP, this.FULLSCREEN_MARGIN) ||
|
|
228
|
+
this.__between(p_w - this.rect.right, this.NO_SNAP, this.FULLSCREEN_MARGIN) ||
|
|
229
|
+
this.__between(p_h - this.rect.bottom, this.NO_SNAP, this.FULLSCREEN_MARGIN)) {
|
|
230
|
+
ghost_info = {x: 0, y: 0, w:p_w, h:p_h, type: "show"}
|
|
231
|
+
} else if (this.__between(this.rect.top, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
232
|
+
ghost_info = {x: 0, y: 0, w:p_w, h:p_h / 2, type: "show"}
|
|
233
|
+
} else if (this.__between(this.rect.left, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
234
|
+
ghost_info = {x: 0, y: 0, w:p_w / 2, h: p_h, type: "show"}
|
|
235
|
+
} else if (this.__between(p_w - this.rect.right, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
236
|
+
ghost_info = {x: p_w / 2, y: 0, w: p_w / 2, h: p_h, type: "show"}
|
|
237
|
+
} else if (this.__between(p_h - this.rect.bottom, this.NO_SNAP, this.SNAP_MARGIN)) {
|
|
238
|
+
ghost_info = {x: 0, y: p_h / 2, w:p_w, h:p_h / 2, type: "show"}
|
|
239
|
+
} else {
|
|
240
|
+
ghost_info = {x: this.rect.left, y: this.rect.top, w: this.rect.width, h: this.rect.height, type: "hide"}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (ghost_info && !this.isParked && !this.isSnap) {
|
|
244
|
+
// this.container.dispatchEvent(new CustomEvent("cocreate-modalghost", {detail: ghost_info}));
|
|
245
|
+
this._ghostProcess(ghost_info)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (this.isSnap) {
|
|
249
|
+
this.el.style.left = this.point.cx + 'px';
|
|
250
|
+
this.el.style.top = this.point.cy + 'px';
|
|
251
|
+
this.el.style.width = this.preSnapped.width + 'px';
|
|
252
|
+
this.el.style.height = this.preSnapped.height + 'px';
|
|
253
|
+
this.isSnap = false;
|
|
254
|
+
} else {
|
|
255
|
+
this.el.style.top = (this.point.cy - c_info.y) + 'px';
|
|
256
|
+
this.el.style.left = (this.point.cx - c_info.x) + 'px';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
eventName = "element-moving";
|
|
260
|
+
if (c_info.isChangeStart) {
|
|
261
|
+
this.clickedInfo.isChangeStart = false;
|
|
262
|
+
eventName = "element-movestart";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this.createEvent(eventName)
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
minMax() {
|
|
271
|
+
if (!this.isSnap) {
|
|
272
|
+
this.isSnap = true;
|
|
273
|
+
this.preSnapped = {x: this.rect.x, y: this.rect.y, width: this.rect.width, height: this.rect.height};
|
|
274
|
+
this.__setBound(this.el, 0, 0, "100%", "100%");
|
|
275
|
+
} else {
|
|
276
|
+
this.isSnap = false;
|
|
277
|
+
this.el.style.left = this.preSnapped.x + 'px';
|
|
278
|
+
this.el.style.top = this.preSnapped.y + 'px';
|
|
279
|
+
this.el.style.width = this.preSnapped.width + 'px';
|
|
280
|
+
this.el.style.height = this.preSnapped.height + 'px';
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
_isMovable() {
|
|
285
|
+
var width = this.rect.width;
|
|
286
|
+
// if (this.isHeader) {
|
|
287
|
+
// width -= 120;
|
|
288
|
+
// }
|
|
289
|
+
return this.point.x > 0 && this.point.x < width && this.point.y > 0 && this.point.y < this.dragAreaHeight;
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Position Events
|
|
294
|
+
* move: element-moving, element-moveend, element-movestart
|
|
295
|
+
**/
|
|
296
|
+
createEvent(eventName) {
|
|
297
|
+
var event = new CustomEvent(eventName, {detail: {element: this.el, instance: this}});
|
|
298
|
+
this.el.dispatchEvent(event);
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
_createGhost: function(ghostClass) {
|
|
302
|
+
var node = document.createElement("div");
|
|
303
|
+
if (!ghostClass) {
|
|
304
|
+
ghostClass = "snap-ghost";
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
node.classList.add(ghostClass);
|
|
308
|
+
this.container.appendChild(node);
|
|
309
|
+
this.ghostEl = node;
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
// this.el.addEventListener('cocreate-modalghost', function(e) {
|
|
313
|
+
// if (_this.selectedModal) {
|
|
314
|
+
// _this._ghostProcess(e.detail)
|
|
315
|
+
// }
|
|
316
|
+
// })
|
|
317
|
+
|
|
318
|
+
_ghostProcess: function(info) {
|
|
319
|
+
this.ghostEl.style.left = info.x + 'px';
|
|
320
|
+
this.ghostEl.style.top = info.y + 'px';
|
|
321
|
+
this.ghostEl.style.width = info.w + 'px';
|
|
322
|
+
this.ghostEl.style.height = info.h + 'px';
|
|
323
|
+
|
|
324
|
+
if (info.type === "show") {
|
|
325
|
+
if (this.ghostEl.style.display === 'none') {
|
|
326
|
+
this.ghostEl.style.display = 'block'
|
|
327
|
+
}
|
|
328
|
+
this.ghostEl.style.opacity = 0.2;
|
|
329
|
+
} else {
|
|
330
|
+
this.ghostEl.style.opacity = 0;
|
|
331
|
+
if (this.ghostEl.style.display !== 'none') {
|
|
332
|
+
this.ghostEl.style.display = 'none'
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return;
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
_selectElement: function(el) {
|
|
339
|
+
this._releaseSelect();
|
|
340
|
+
this.container['selectedPositionElement'] = this.el
|
|
341
|
+
if (this.el) {
|
|
342
|
+
this.el.style.zIndex = this.SELECT_ZINDEX;
|
|
343
|
+
this.el.classList.add('modal_selected');
|
|
344
|
+
// this.ghostEl.style.width = 0;
|
|
345
|
+
// this.ghostEl.style.height = 0;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
_releaseSelect: function() {
|
|
350
|
+
let el = this.container['selectedPositionElement']
|
|
351
|
+
if (!el) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
el.style.zIndex = this.UNSELECT_ZINDEX;
|
|
355
|
+
el.classList.remove("modal_selected");
|
|
356
|
+
},
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export default position;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const TerserPlugin = require("terser-webpack-plugin")
|
|
3
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
4
|
+
let isProduction = process.env.NODE_ENV === "production"
|
|
5
|
+
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
entry: {
|
|
9
|
+
"CoCreate-position": "./src/index.js",
|
|
10
|
+
},
|
|
11
|
+
output: {
|
|
12
|
+
path: path.resolve(__dirname, "dist"),
|
|
13
|
+
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
14
|
+
libraryTarget: "umd",
|
|
15
|
+
libraryExport: "default",
|
|
16
|
+
library: ["CoCreate", "modal"],
|
|
17
|
+
globalObject: "this",
|
|
18
|
+
// publicPath: 'https://server.cocreate.app/CoCreateJS/dist/'
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
plugins: [
|
|
22
|
+
new CleanWebpackPlugin(),
|
|
23
|
+
new MiniCssExtractPlugin({
|
|
24
|
+
filename: "[name].css",
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
// Default mode for Webpack is production.
|
|
28
|
+
// Depending on mode Webpack will apply different things
|
|
29
|
+
// on final bundle. For now we don't need production's JavaScript
|
|
30
|
+
// minifying and other thing so let's set mode to development
|
|
31
|
+
mode: isProduction ? "production" : "development",
|
|
32
|
+
module: {
|
|
33
|
+
rules: [
|
|
34
|
+
{
|
|
35
|
+
test: /.js$/,
|
|
36
|
+
exclude: /(node_modules)/,
|
|
37
|
+
use: {
|
|
38
|
+
loader: "babel-loader",
|
|
39
|
+
options: {
|
|
40
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
test: /.css$/i,
|
|
46
|
+
use: [
|
|
47
|
+
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
48
|
+
"file-loader",
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// add source map
|
|
55
|
+
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
|
56
|
+
|
|
57
|
+
optimization: {
|
|
58
|
+
minimize: true,
|
|
59
|
+
minimizer: [
|
|
60
|
+
new TerserPlugin({
|
|
61
|
+
extractComments: true,
|
|
62
|
+
// cache: true,
|
|
63
|
+
parallel: true,
|
|
64
|
+
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
65
|
+
terserOptions: {
|
|
66
|
+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
67
|
+
// extractComments: 'all',
|
|
68
|
+
compress: {
|
|
69
|
+
drop_console: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
splitChunks: {
|
|
75
|
+
chunks: "all",
|
|
76
|
+
minSize: 200,
|
|
77
|
+
// maxSize: 99999,
|
|
78
|
+
//minChunks: 1,
|
|
79
|
+
|
|
80
|
+
cacheGroups: {
|
|
81
|
+
defaultVendors: false,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}
|