a-frame-components
Advanced tools
Comparing version 1.0.333 to 1.0.334
@@ -17,2 +17,3 @@ var __assign = (this && this.__assign) || function () { | ||
import mixin from '../../gui/components/mixin'; | ||
import { updateAttributeEl, watchAttribute } from '../useEventListenerOn'; | ||
var THREE = window.THREE; | ||
@@ -48,2 +49,3 @@ function loadFontAtlas(path) { | ||
icon: { type: 'string', default: '' }, | ||
direct: { type: 'boolean', default: false }, | ||
speed: { type: 'string', default: 0 }, | ||
@@ -217,2 +219,24 @@ iconFontSize: { type: 'string', default: '' }, | ||
me.loadedFont = true; | ||
watchAttribute(me.el, { | ||
options: function (name, value, el) { | ||
if (JSON.stringify(value) !== JSON.stringify(me.oldOptions || '')) { | ||
me.directOptions = value; | ||
var options = me.getOptions(); | ||
me.options = options; | ||
var keys = Object.keys(me.visibleObjects); | ||
for (var k = 0; k < keys.length; k++) { | ||
var key = parseInt(keys[k]); | ||
var vo = me.visibleObjects[key]; | ||
try { | ||
if (vo === null || vo === void 0 ? void 0 : vo.parentNode) | ||
vo.parentNode.removeChild(vo); | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
delete me.visibleObjects[key]; | ||
} | ||
} | ||
} | ||
}); | ||
} }, mixin), { getWidth: function () { | ||
@@ -224,19 +248,19 @@ return parseFloat("".concat(this.data.width)); | ||
var me = this; | ||
if (JSON.stringify(this.data.options) !== JSON.stringify(oldData.options || '')) { | ||
var options = me.getOptions(); | ||
me.options = options; | ||
var keys = Object.keys(me.visibleObjects); | ||
for (var k = 0; k < keys.length; k++) { | ||
var key = parseInt(keys[k]); | ||
// if (JSON.stringify(this.data.options?.[key]) !== JSON.stringify(oldData.options?.[key] || '')) { | ||
var vo = me.visibleObjects[key]; | ||
try { | ||
if (vo === null || vo === void 0 ? void 0 : vo.parentNode) | ||
vo.parentNode.removeChild(vo); | ||
if (!this.data.direct) { | ||
if (JSON.stringify(this.data.options) !== JSON.stringify(oldData.options || '')) { | ||
var options = me.getOptions(); | ||
me.options = options; | ||
var keys = Object.keys(me.visibleObjects); | ||
for (var k = 0; k < keys.length; k++) { | ||
var key = parseInt(keys[k]); | ||
var vo = me.visibleObjects[key]; | ||
try { | ||
if (vo === null || vo === void 0 ? void 0 : vo.parentNode) | ||
vo.parentNode.removeChild(vo); | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
delete me.visibleObjects[key]; | ||
} | ||
catch (e) { | ||
console.log(e); | ||
} | ||
delete me.visibleObjects[key]; | ||
// } | ||
} | ||
@@ -394,3 +418,8 @@ } | ||
var item = document.createElement(me.data.itemtemplate); | ||
item.setAttribute('options', JSON.stringify(__assign(__assign({}, options), { imageMargin: me.imageMargin, selectionevent: me.data.selectionevent, guiItem: me.guiItem, value: value, id: id, text: text, url: url }))); | ||
if (me.data.direct) { | ||
updateAttributeEl(item, 'optons', __assign(__assign({}, options), { imageMargin: me.imageMargin, selectionevent: me.data.selectionevent, guiItem: me.guiItem, value: value, id: id, text: text, url: url })); | ||
} | ||
else { | ||
item.setAttribute('options', JSON.stringify(__assign(__assign({}, options), { imageMargin: me.imageMargin, selectionevent: me.data.selectionevent, guiItem: me.guiItem, value: value, id: id, text: text, url: url }))); | ||
} | ||
item.setAttribute('selectionevent', this.data.selectionevent); | ||
@@ -452,6 +481,14 @@ var entity_1 = document.createElement('a-entity'); | ||
}, getOptions: function () { | ||
var _a, _b; | ||
if ((_b = (_a = this === null || this === void 0 ? void 0 : this.data) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.length) { | ||
return this.data.options; | ||
var _a, _b, _c; | ||
var me = this; | ||
if (this.data.direct) { | ||
if ((_a = me === null || me === void 0 ? void 0 : me.directOptions) === null || _a === void 0 ? void 0 : _a.length) { | ||
return me === null || me === void 0 ? void 0 : me.directOptions; | ||
} | ||
} | ||
else { | ||
if ((_c = (_b = this === null || this === void 0 ? void 0 : this.data) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.length) { | ||
return this.data.options; | ||
} | ||
} | ||
return [ | ||
@@ -575,3 +612,4 @@ "Apple", | ||
selected: 'infinity-list.selected', | ||
hideclose: 'infinity-list.hideClose' | ||
hideclose: 'infinity-list.hideClose', | ||
'direct': 'infinity-list.direct', | ||
} | ||
@@ -578,0 +616,0 @@ }); |
@@ -169,5 +169,10 @@ import { useEffect, useState, useRef } from 'react'; | ||
if (el) { | ||
raiseCustomEvent('frame-update-attribute', { name: name, value: value }, el); | ||
updateAttributeEl(el, name, value); | ||
} | ||
} | ||
export function updateAttributeEl(el, name, value) { | ||
if (el) { | ||
raiseCustomEvent('frame-update-attribute', { name: name, value: value }, el, { bubble: false }); | ||
} | ||
} | ||
export function watchAttribute(el, args) { | ||
@@ -174,0 +179,0 @@ el.addEventListener('frame-update-attribute', function (evt) { |
@@ -0,1 +1,12 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -111,5 +122,5 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
*/ | ||
export function raiseCustomEvent(eventName, detail, canvasLayer) { | ||
export function raiseCustomEvent(eventName, detail, canvasLayer, opts) { | ||
// Create a custom event with the given name and detail | ||
var event = new CustomEvent(eventName, { detail: detail, bubbles: true }); | ||
var event = new CustomEvent(eventName, __assign({ detail: detail, bubbles: true }, (opts || {}))); | ||
// Dispatch the event on the window object or another suitable target | ||
@@ -116,0 +127,0 @@ if (canvasLayer) { |
{ | ||
"name": "a-frame-components", | ||
"version": "1.0.333", | ||
"version": "1.0.334", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,2 +8,3 @@ import { AFRAME } from '../systems/brush'; | ||
import mixin from '../../gui/components/mixin'; | ||
import { updateAttribute, updateAttributeEl, watchAttribute } from '../useEventListenerOn'; | ||
const THREE: any = (window as any).THREE; | ||
@@ -46,2 +47,3 @@ | ||
icon: { type: 'string', default: '' }, | ||
direct: { type: 'boolean', default: false }, | ||
speed: { type: 'string', default: 0 }, | ||
@@ -223,2 +225,22 @@ iconFontSize: { type: 'string', default: '' }, | ||
me.loadedFont = true; | ||
watchAttribute(me.el, { | ||
options: (name: string, value: any, el: any) => { | ||
if (JSON.stringify(value) !== JSON.stringify(me.oldOptions || '')) { | ||
me.directOptions = value; | ||
let options = me.getOptions(); | ||
me.options = options; | ||
let keys = Object.keys(me.visibleObjects); | ||
for (let k = 0; k < keys.length; k++) { | ||
let key = parseInt(keys[k]); | ||
let vo = me.visibleObjects[key]; | ||
try { | ||
if (vo?.parentNode) | ||
vo.parentNode.removeChild(vo); | ||
} catch (e) { console.log(e) } | ||
delete me.visibleObjects[key] | ||
} | ||
} | ||
} | ||
}) | ||
}, | ||
@@ -235,16 +257,16 @@ ...mixin, | ||
let me = this; | ||
if (JSON.stringify(this.data.options) !== JSON.stringify(oldData.options || '')) { | ||
let options = me.getOptions(); | ||
me.options = options; | ||
let keys = Object.keys(me.visibleObjects); | ||
for (let k = 0; k < keys.length; k++) { | ||
let key = parseInt(keys[k]); | ||
// if (JSON.stringify(this.data.options?.[key]) !== JSON.stringify(oldData.options?.[key] || '')) { | ||
let vo = me.visibleObjects[key]; | ||
try { | ||
if (vo?.parentNode) | ||
vo.parentNode.removeChild(vo); | ||
} catch (e) { console.log(e) } | ||
delete me.visibleObjects[key] | ||
// } | ||
if (!this.data.direct) { | ||
if (JSON.stringify(this.data.options) !== JSON.stringify(oldData.options || '')) { | ||
let options = me.getOptions(); | ||
me.options = options; | ||
let keys = Object.keys(me.visibleObjects); | ||
for (let k = 0; k < keys.length; k++) { | ||
let key = parseInt(keys[k]); | ||
let vo = me.visibleObjects[key]; | ||
try { | ||
if (vo?.parentNode) | ||
vo.parentNode.removeChild(vo); | ||
} catch (e) { console.log(e) } | ||
delete me.visibleObjects[key] | ||
} | ||
} | ||
@@ -402,12 +424,26 @@ } | ||
let item = document.createElement(me.data.itemtemplate); | ||
item.setAttribute('options', JSON.stringify({ | ||
...options, | ||
imageMargin: me.imageMargin, | ||
selectionevent: me.data.selectionevent, | ||
guiItem: me.guiItem, | ||
value, | ||
id, | ||
text, | ||
url, | ||
})); | ||
if (me.data.direct) { | ||
updateAttributeEl(item, 'optons', { | ||
...options, | ||
imageMargin: me.imageMargin, | ||
selectionevent: me.data.selectionevent, | ||
guiItem: me.guiItem, | ||
value, | ||
id, | ||
text, | ||
url, | ||
}) | ||
} | ||
else { | ||
item.setAttribute('options', JSON.stringify({ | ||
...options, | ||
imageMargin: me.imageMargin, | ||
selectionevent: me.data.selectionevent, | ||
guiItem: me.guiItem, | ||
value, | ||
id, | ||
text, | ||
url, | ||
})); | ||
} | ||
item.setAttribute('selectionevent', this.data.selectionevent); | ||
@@ -486,5 +522,13 @@ let entity: any = document.createElement('a-entity'); | ||
getOptions: function () { | ||
if (this?.data?.options?.length) { | ||
return this.data.options; | ||
let me = this; | ||
if (this.data.direct) { | ||
if (me?.directOptions?.length) { | ||
return me?.directOptions; | ||
} | ||
} | ||
else { | ||
if (this?.data?.options?.length) { | ||
return this.data.options; | ||
} | ||
} | ||
return [ | ||
@@ -621,3 +665,4 @@ "Apple", | ||
selected: 'infinity-list.selected', | ||
hideclose: 'infinity-list.hideClose' | ||
hideclose: 'infinity-list.hideClose', | ||
'direct': 'infinity-list.direct', | ||
} | ||
@@ -624,0 +669,0 @@ }); |
@@ -198,8 +198,14 @@ import { useEffect, useState, useRef } from 'react'; | ||
if (el) { | ||
raiseCustomEvent('frame-update-attribute', { name, value }, el); | ||
updateAttributeEl(el, name, value); | ||
} | ||
} | ||
export function updateAttributeEl(el: any, name: string, value: any) { | ||
if (el) { | ||
raiseCustomEvent('frame-update-attribute', { name, value }, el, { bubble: false }); | ||
} | ||
} | ||
export function watchAttribute(el: any, args: { | ||
[name: string]: (name: string, value: string, el: any) => void | ||
[name: string]: (name: string, value: any, el: any) => void | ||
}) { | ||
@@ -206,0 +212,0 @@ el.addEventListener('frame-update-attribute', (evt) => { |
@@ -68,5 +68,5 @@ export function uuidv4(): string { | ||
*/ | ||
export function raiseCustomEvent<T>(eventName: string, detail: T, canvasLayer?: any): void { | ||
export function raiseCustomEvent<T>(eventName: string, detail: T, canvasLayer?: any, opts?: any): void { | ||
// Create a custom event with the given name and detail | ||
const event = new CustomEvent<T>(eventName, { detail, bubbles: true }); | ||
const event = new CustomEvent<T>(eventName, { detail, bubbles: true, ...(opts || {}) }); | ||
// Dispatch the event on the window object or another suitable target | ||
@@ -73,0 +73,0 @@ if (canvasLayer) { |
@@ -10,3 +10,3 @@ // aframe.d.ts | ||
export function watchAttribute(el: any, args: { | ||
[name: string]: (name: string, value: string, el: any) => void | ||
[name: string]: (name: string, value: any, el: any) => void | ||
}) | ||
@@ -13,0 +13,0 @@ export function createElement(elementType: any, attributesDic: { [str: string]: any }): (moreAttr: { [str: string]: any }) => Element; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1792483
30669