aframe-href-component
Advanced tools
Comparing version 0.4.0 to 0.5.0
32
index.js
@@ -33,10 +33,38 @@ if (typeof AFRAME === 'undefined') { | ||
if (target) { | ||
var animation = ''; | ||
var exitAnimation = null; | ||
var animationendHandler = null; | ||
console.log('target to ' + target); | ||
if (target.indexOf('#') >= 0) { | ||
var li = target.split('#'); | ||
target = li[0]; | ||
animation = li[1]; | ||
console.log('target to ' + target + ' & animate ' + animation); | ||
} | ||
switch(target) { | ||
case '_blank': | ||
window.open(url); | ||
if (animation) { | ||
exitAnimation = document.getElementById(animation); | ||
exitAnimation.addEventListener('animationend', function animationendHandler() { | ||
exitAnimation.removeEventListener('animationend', animationendHandler); | ||
window.open(url); | ||
}); | ||
this.el.emit('href'); | ||
} else { | ||
window.open(url); | ||
} | ||
break; | ||
case 'window': | ||
default: | ||
window.location.href = url; | ||
if (animation) { | ||
exitAnimation = document.getElementById(animation); | ||
exitAnimation.addEventListener('animationend', function animationendHandler() { | ||
exitAnimation.removeEventListener('animationend', animationendHandler); | ||
console.log() | ||
window.location.href = url; | ||
}); | ||
this.el.emit('href'); | ||
} else { | ||
window.location.href = url; | ||
} | ||
break; | ||
@@ -43,0 +71,0 @@ } |
{ | ||
"name": "aframe-href-component", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Hyper Link component for A-Frame.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,6 @@ ## aframe-href-component | ||
### Animation support (experimental) | ||
When link is clicked, the href-component will emit a `href` event within this object. You can append the animation id in `target` attribute, such as `target="#out-animation"` (a shortcut of `target="window#out-animation"`) or `target="_blank#out-animation"` to trigger the animation directly. If your animation is not defined within this object, you should emit the event manually. | ||
### Anchor support (experimental) | ||
@@ -15,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
68
15973
12
89