Skip to content

Commit

Permalink
Add area render (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYSzys authored Aug 24, 2018
1 parent bb55529 commit bdcf8ab
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 19 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vue-canvas-nest

[![Vue](https://img.shields.io/badge/Vue-^2.5-brightgreen.svg)](https://vuejs.org/)
[![Vue](https://img.shields.io/badge/Vue-2.5-brightgreen.svg)](https://vuejs.org/)
[![Travis CI](https://travis-ci.org/ZYSzys/vue-canvas-nest.svg?branch=master)](https://travis-ci.org/ZYSzys/vue-canvas-nest)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![NPM version](https://img.shields.io/npm/v/vue-canvas-nest.svg?style=flat)](https://npmjs.org/package/vue-canvas-nest)
Expand Down Expand Up @@ -36,14 +36,14 @@ export default {

### How to use

#### Simply use:
#### Simply use
```html
<vue-canvas-nest></vue-canvas-nest>
```

#### With config:
#### With config or el(area render)
```html
<vue-canvas-nest :config="{color:'255,0,0', count: 88}"></vue-canvas-nest>
<vue-canvas-nest :config="{color:'255,0,0', count: 88}" :el="'#area'"></vue-canvas-nest>
```

## Config
Expand All @@ -53,6 +53,8 @@ export default {
- **`count`**: the number of lines, default: `99`.
- **`zIndex`**: the index of z space, default: `-1`.

**Note: Render the whole page if no el passed by default.**

#### Example:
```js
const config = {
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-canvas-nest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vue-canvas-nest.min.js.map

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions example/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div id="app">
<vue-canvas-nest :config="config" :el="'#area'"></vue-canvas-nest>
<div id="cn-router">
<router-link to="/red"><span style="color: red"> Red </span></router-link>
<router-link to="/green"><span> Green </span></router-link>
Expand All @@ -22,6 +23,8 @@
<li><a href="http://vue-loader.vuejs.org/" target="_blank">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank">awesome-vue</a></li>
</ul>
<div id="area" style="width: 400px;height: 300px;position: absolute;right: 0;bottom: 0;border: dashed 1px;">
</div>
</div>
</template>
<script>
Expand All @@ -33,9 +36,10 @@ export default {
return {
msg: 'Welcome to Your Vue.js App',
config: {
color: '0,0,255',
count: 150,
}
color: '0,0,0',
count: 70,
},
el: '#area'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/dist/vue-canvas-nest-example.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/dist/vue-canvas-nest-example.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/rgb/Blue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default {
return {
config: {
color: '0,0,255',
count: 100,
count: 150,
opacity: 0.9,
zIndex: 0,
}
}
}
}
</script>
</script>
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
"directories": {
"example": "example"
},
"files": [
"src",
"dist"
],
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot --config=./build/webpack.dev.config.js",
"dev": "npm run build && cross-env NODE_ENV=development webpack-dev-server --open --hot --config=./build/webpack.dev.config.js",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config=./build/webpack.prod.config.js",
"example": "cross-env NODE_ENV=production webpack --progress --hide-modules --config=./build/webpack.dev.config.js"
},
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/vueCanvasNest.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="vue-canvas-nest-element" ref="vue_canvas_nest_element">
<div class="vue-canvas-nest-element">
</div>
</template>
<script>
Expand All @@ -17,19 +17,24 @@ export default {
zIndex: -1
}
}
},
el: {
type: String,
default: '.vue-canvas-nest-element'
}
},
mounted() {
this.createCanvasNest()
},
methods: {
createCanvasNest() {
const el = this.$refs.vue_canvas_nest_element
this.cn = new CanvasNest(el, this.config)
const elm = document.querySelector(this.el)
this.cn = new CanvasNest(elm, this.config)
}
},
beforeDestroy () {
this.$refs.vue_canvas_nest_element.innerHTML = ''
const elm = document.querySelector(this.el)
this.cn.destroy()
}
}
Expand Down

0 comments on commit bdcf8ab

Please sign in to comment.