Skip to content

Commit

Permalink
fix commonjs import
Browse files Browse the repository at this point in the history
  • Loading branch information
Twiknight committed Dec 27, 2015
1 parent af02f24 commit e34b77b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-transition",
"version": "0.0.1",
"version": "0.0.2",
"description": "A transition component for Vue",
"main": "vue-transition.js",
"repository":{
Expand Down
95 changes: 48 additions & 47 deletions vue-transition.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
;(function(){
var trans = Vue.extend({
template: '<element></element>',
props: ['id','options','source'],
methods: {
play: function(options){
var vm = this;


var opts = options || vm.options;
var el = vm.$el.parentElement;
function install(Vue){
var trans = Vue.extend({
template: '<element></element>',
props: ['id','options','source'],
methods: {
play: function(options){
var vm = this;

return new Promise(function(resolve, reject) {
if(vm.regx.test(el.className)){
reject("Target class already exist.");
}else{
el.style.transition = opts;
el.className += " "+vm.source;
var opts = options || vm.options;
var el = vm.$el.parentElement;

vm.$once('transitionend', resolve);
}
});
},
rollback:function(options){
var vm = this;
var opts = options || vm.options;
var el = vm.$el.parentElement;
return new Promise(function(resolve, reject) {
if(vm.regx.test(el.className)){
reject("Target class already exist.");
}else{
el.style.transition = opts;
el.className += " "+vm.source;

return new Promise(function(resolve, reject) {
if(vm.regx.test(el.className)){
el.style.transition = opts;
el.className = el.className.replace(vm.regx,'');
vm.$once('transitionend', resolve);
}
});
},
rollback:function(options){
var vm = this;
var opts = options || vm.options;
var el = vm.$el.parentElement;

vm.$once('transitionend', resolve);
}else{
reject("This transition haven't been played.");
}
});
}
},
created(){
this.regx = new RegExp('\\b'+this.source+'\\b');
},
ready(){
var vm = this;
var el = vm.$el.parentElement;
return new Promise(function(resolve, reject) {
if(vm.regx.test(el.className)){
el.style.transition = opts;
el.className = el.className.replace(vm.regx,'');

el.addEventListener('transitionend', function(){
vm.$emit('transitionend');
})
vm.$parent.transitions = vm.$parent.transitions || {};
vm.$parent.transitions[vm.id] = vm;
}
});
vm.$once('transitionend', resolve);
}else{
reject("This transition haven't been played.");
}
});
}
},
created(){
this.regx = new RegExp('\\b'+this.source+'\\b');
},
ready(){
var vm = this;
var el = vm.$el.parentElement;

function install(Vue){
el.addEventListener('transitionend', function(){
vm.$emit('transitionend');
})
vm.$parent.transitions = vm.$parent.transitions || {};
vm.$parent.transitions[vm.id] = vm;
}
});
Vue.component('transition',trans);
}

Expand Down

0 comments on commit e34b77b

Please # to comment.