fixed regression

This commit is contained in:
Leon van Kammen 2023-06-22 13:59:17 +02:00
parent 131e39192f
commit 85dd26632c
7 changed files with 16 additions and 10 deletions

View file

@ -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!
})
}

View file

@ -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!
})
}

View file

@ -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!
})
}

View file

@ -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)

View file

@ -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

View file

@ -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} )
}

View file

@ -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!
})
}