diff --git a/dist/xrfragment.aframe.js b/dist/xrfragment.aframe.js index 711d006..a4734ae 100644 --- a/dist/xrfragment.aframe.js +++ b/dist/xrfragment.aframe.js @@ -954,7 +954,6 @@ xrf.navigator.to = (url,flags) => { return new Promise( (resolve,reject) => { let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url) - console.log(url) if( !file || xrf.model.file == file ){ // we're already loaded xrf.eval( url, xrf.model, flags ) // and eval local URI XR fragments @@ -996,6 +995,7 @@ xrf.navigator.init = () => { xrf.navigator.updateHash = (hash) => { if( hash == document.location.hash || hash.match(/\|/) ) return // skip unnecesary pushState triggers + console.log(`URL: ${document.location.search.substr(1)}#${hash}`) document.location.hash = hash xrf.emit('updateHash', {hash} ) } @@ -1107,12 +1107,13 @@ xrf.frag.href = function(v, opts){ }else if( mesh.material){ mesh.material = mesh.material.clone() } let click = mesh.userData.XRF.href.exec = (e) => { + let isLocal = v.string[0] == '#' let lastPos = `#pos=${camera.position.x},${camera.position.y},${camera.position.z}` xrf .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree .then( () => { - xrf.navigator.to(lastPos) // commit last position const flags = v.string[0] == '#' && v.string.match(/(\||#q)/) ? xrf.XRF.PV_OVERRIDE : undefined + if( !isLocal || v.string.match(/pos=/) ) xrf.navigator.to(lastPos) // commit last position xrf.navigator.to(v.string,flags) // let's surf to HREF! }) } diff --git a/dist/xrfragment.three.js b/dist/xrfragment.three.js index ef2265d..821f768 100644 --- a/dist/xrfragment.three.js +++ b/dist/xrfragment.three.js @@ -954,7 +954,6 @@ xrf.navigator.to = (url,flags) => { return new Promise( (resolve,reject) => { let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url) - console.log(url) if( !file || xrf.model.file == file ){ // we're already loaded xrf.eval( url, xrf.model, flags ) // and eval local URI XR fragments @@ -996,6 +995,7 @@ xrf.navigator.init = () => { xrf.navigator.updateHash = (hash) => { if( hash == document.location.hash || hash.match(/\|/) ) return // skip unnecesary pushState triggers + console.log(`URL: ${document.location.search.substr(1)}#${hash}`) document.location.hash = hash xrf.emit('updateHash', {hash} ) } @@ -1107,12 +1107,13 @@ xrf.frag.href = function(v, opts){ }else if( mesh.material){ mesh.material = mesh.material.clone() } let click = mesh.userData.XRF.href.exec = (e) => { + let isLocal = v.string[0] == '#' let lastPos = `#pos=${camera.position.x},${camera.position.y},${camera.position.z}` xrf .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree .then( () => { - xrf.navigator.to(lastPos) // commit last position const flags = v.string[0] == '#' && v.string.match(/(\||#q)/) ? xrf.XRF.PV_OVERRIDE : undefined + if( !isLocal || v.string.match(/pos=/) ) xrf.navigator.to(lastPos) // commit last position xrf.navigator.to(v.string,flags) // let's surf to HREF! }) } diff --git a/dist/xrfragment.three.module.js b/dist/xrfragment.three.module.js index 3308e2f..4100388 100644 --- a/dist/xrfragment.three.module.js +++ b/dist/xrfragment.three.module.js @@ -954,7 +954,6 @@ xrf.navigator.to = (url,flags) => { return new Promise( (resolve,reject) => { let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url) - console.log(url) if( !file || xrf.model.file == file ){ // we're already loaded xrf.eval( url, xrf.model, flags ) // and eval local URI XR fragments @@ -996,6 +995,7 @@ xrf.navigator.init = () => { xrf.navigator.updateHash = (hash) => { if( hash == document.location.hash || hash.match(/\|/) ) return // skip unnecesary pushState triggers + console.log(`URL: ${document.location.search.substr(1)}#${hash}`) document.location.hash = hash xrf.emit('updateHash', {hash} ) } @@ -1107,12 +1107,13 @@ xrf.frag.href = function(v, opts){ }else if( mesh.material){ mesh.material = mesh.material.clone() } let click = mesh.userData.XRF.href.exec = (e) => { + let isLocal = v.string[0] == '#' let lastPos = `#pos=${camera.position.x},${camera.position.y},${camera.position.z}` xrf .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree .then( () => { - xrf.navigator.to(lastPos) // commit last position const flags = v.string[0] == '#' && v.string.match(/(\||#q)/) ? xrf.XRF.PV_OVERRIDE : undefined + if( !isLocal || v.string.match(/pos=/) ) xrf.navigator.to(lastPos) // commit last position xrf.navigator.to(v.string,flags) // let's surf to HREF! }) } diff --git a/example/aframe/sandbox/index.html b/example/aframe/sandbox/index.html index ae7f6dd..98eef6a 100644 --- a/example/aframe/sandbox/index.html +++ b/example/aframe/sandbox/index.html @@ -43,7 +43,7 @@ window.$ = (s) => document.querySelector(s) window.notify = notify(window) console.log = ( (log) => function(str){ - if( String(str).match(/#.*=/) ) window.notify(str) + if( String(str).match(/:.*#/) ) window.notify(str) log(str) })(console.log) diff --git a/example/assets/js/utils.js b/example/assets/js/utils.js index fd3ee10..095ee74 100644 --- a/example/assets/js/utils.js +++ b/example/assets/js/utils.js @@ -83,7 +83,9 @@ function SnackBar(userOptions) { var _Options = _OptionDefaults; function _Create() { - _Container = document.getElementsByClassName("js-snackbar-container")[0]; + let _Containers = [ ...document.querySelectorAll(".js-snackbar-container") ] + _Containers.map( (c) => c.remove() ) + _Container = null if (!_Container) { // need to create a new container for notifications diff --git a/src/3rd/js/three/navigator.js b/src/3rd/js/three/navigator.js index 16e9806..6066521 100644 --- a/src/3rd/js/three/navigator.js +++ b/src/3rd/js/three/navigator.js @@ -5,7 +5,6 @@ xrf.navigator.to = (url,flags) => { return new Promise( (resolve,reject) => { let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url) - console.log(url) if( !file || xrf.model.file == file ){ // we're already loaded xrf.eval( url, xrf.model, flags ) // and eval local URI XR fragments @@ -47,6 +46,7 @@ xrf.navigator.init = () => { xrf.navigator.updateHash = (hash) => { if( hash == document.location.hash || hash.match(/\|/) ) return // skip unnecesary pushState triggers + console.log(`URL: ${document.location.search.substr(1)}#${hash}`) document.location.hash = hash xrf.emit('updateHash', {hash} ) } diff --git a/src/3rd/js/three/xrf/href.js b/src/3rd/js/three/xrf/href.js index e5b016d..3ae55f2 100644 --- a/src/3rd/js/three/xrf/href.js +++ b/src/3rd/js/three/xrf/href.js @@ -90,12 +90,13 @@ xrf.frag.href = function(v, opts){ }else if( mesh.material){ mesh.material = mesh.material.clone() } let click = mesh.userData.XRF.href.exec = (e) => { + let isLocal = v.string[0] == '#' let lastPos = `#pos=${camera.position.x},${camera.position.y},${camera.position.z}` xrf .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree .then( () => { - xrf.navigator.to(lastPos) // commit last position const flags = v.string[0] == '#' && v.string.match(/(\||#q)/) ? xrf.XRF.PV_OVERRIDE : undefined + if( !isLocal || v.string.match(/pos=/) ) xrf.navigator.to(lastPos) // commit last position xrf.navigator.to(v.string,flags) // let's surf to HREF! }) }