[go: nahoru, domu]

Skip to content

Commit

Permalink
Added custom loader
Browse files Browse the repository at this point in the history
  • Loading branch information
ftgibran committed Aug 13, 2017
1 parent 6b540cd commit 49ed5a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/CustomLoader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div :style="{color: this.color}">
<strong>Loading...</strong>
</div>
</template>

<script>
export default {
props: ['color']
}
</script>
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ var api = {}

var module = {
effects: [],
loader: {},

addEffect: function (name, func) {
module.effects.push({name: name, func: func})
},

addLoader: function (name, component) {
Object.assign(module.loader, {[name]: component})
},

setAPI: function (obj) {
api = obj
},
Expand Down Expand Up @@ -39,6 +44,7 @@ var module = {
}

Vue.component('ApiRequest', ApiRequest)
Vue.options.components['ApiRequest'].mixin({components: module.loader})
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import AppRouter from './service/AppRouter'
import AppResource from './service/AppResource'
import VueApiRequest from './index'
import { TweenLite, Power2 } from 'gsap'
import CustomLoader from './components/CustomLoader.vue'

VueApiRequest.setAPI(AppResource)

VueApiRequest.addLoader('CustomLoader', CustomLoader)

VueApiRequest.addEffect('blur', (el) => {
el.style.filter = 'blur(10px)'
TweenLite.to(el, 0.5, {
Expand Down

0 comments on commit 49ed5a1

Please sign in to comment.