- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
本质上,我在 aframe 中有一个模式窗口,我试图通过 JavaScript 添加一个关闭按钮,但我无法弄清楚。
链接到以下项目:
https://andrewmc1994.github.io/Image-Link-Test/
如果您突出显示指南针图标,您就会明白我的意思。
这是一个大学项目,我在网上查看了各种方法,但似乎都不起作用,所以这就是我来这里的原因。
<a-entity ui-modal="triggerElement:#selection;" visible="false">
<a-image src="#submenu" scale="3.5 3.5 0" position="0 -0.25 2" src-fit></a-image>
<a-image position="-1 -0.25 2.1" class="clickable" src="#tqicon" scale="0.7 0.7 0" link="href:location1.html; on: click; visualAspectEnabled: false" src-fit></a-image>
<a-image position="0 -0.25 2.1" class="clickable" src="#acicon" scale="0.7 0.7 0" link="href:location3.html; on: click; visualAspectEnabled: false" src-fit></a-image>
<a-image position="1 -0.25 2.1" class="clickable" src="#bchicon" scale="0.7 0.7 0" link="href:location2.html; on: click; visualAspectEnabled: false" src-fit></a-image>
<a-image position="1.4 0 2.1" class="clickable" src="#close" scale="0.1 0.1 0" id="close" src-fit></a-image>
</a-entity>
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {
/**
* UI modal component for A-Frame.
*/
if (typeof AFRAME === 'undefined') {
throw new Error('Component attempted to register before AFRAME was available.');
}
AFRAME.registerComponent('ui-modal', {
schema: {
trigger: {
default: 'click'
},
triggerElement: {
default: '',
},
zpos: {
default: -4
}
},
init: function() {
document.querySelector(this.data.triggerElement).addEventListener(this.data.trigger, this.eventHandler.bind(this));
this.cameraEl = document.querySelector('a-entity[camera]');
this.yaxis = new THREE.Vector3(0, 0, 0);
this.zaxis = new THREE.Vector3(0, 0, 0);
this.pivot = new THREE.Object3D();
this.el.object3D.position.set(0, this.cameraEl.object3D.getWorldPosition().y, this.data.zpos);
this.el.sceneEl.object3D.add(this.pivot);
this.pivot.add(this.el.object3D);
},
eventHandler: function(evt) {
if (this.el.getAttribute('visible') === false) {
var direction = this.zaxis.clone();
direction.applyQuaternion(this.cameraEl.object3D.quaternion);
var ycomponent = this.yaxis.clone().multiplyScalar(direction.dot(this.yaxis));
direction.sub(ycomponent);
direction.normalize();
this.pivot.quaternion.setFromUnitVectors(this.zaxis, direction);
this.pivot.position.copy(this.cameraEl.object3D.getWorldPosition());
this.el.setAttribute('visible', true);
} else if (this.el.getAttribute('visible') === true) {
this.el.setAttribute('visible', false);
}
},
update: function (oldData) {},
remove: function() {}
});
/***/ }
/******/ ]);
因此,预期结果是用户打开模式窗口,然后能够使用简单的按钮将其关闭。
非常感谢任何帮助。
最佳答案
您只需向现有的关闭按钮添加任何功能即可。您的 eventHandler
已经包含用于显示/隐藏 UI 的逻辑,因此只需向关闭按钮添加一个监听器即可:
let closeBtn = document.getElementById("close") one close button
closeBtn.addEventListener(this.data.trigger, this.eventHandler.bind(this))
单击时 - 它将隐藏 UI。
但是,还有更多带有 ui-modal
组件的元素,它们的 eventHandler
会触发 setAttribute("visible", "")
部分。
解决这个问题最简单的方法是
closeBtn.addEventListener(this.data.trigger, e => {
this.el.setAttribute("visible", "false")
})
让关闭按钮隐藏该元素,这里无需执行任何操作。
<小时/>至于阿克塞尔的担忧,你其实不需要做太多比较。您可以将它们视为 bool 值:这是有效的:
if (this.el.getAttribute("visible") {
// hide
} else {
// show
}
还有这个:
// toggle visibility
this.el.setAttribute("visible", !this.el.getAttribute("visible")
您可以在this查看 fiddle 。
关于javascript - 如何在 aframe 中向此 JavaScript 添加关闭按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55816229/
我想要一个没有标题栏的 qtip2 工具提示,但在角落里有一个关闭图标。有没有办法指定它,或者我是否必须使用创建它的代码?我正在考虑将按钮向左或向右 float 的东西,允许其余内容填充工具提示 di
我有一个 Jframe 窗口,里面有一个按钮。通过单击该按钮,它会打开一个新的 JFrame 窗口。但是当我关闭这个窗口时,它会自动关闭第一个带有按钮的 Jframe 窗口。当我关闭第二个 Jfram
我有一个关闭按钮。如何使关闭按钮在向下滚动页面时悬停?现在它位于顶部。当我们向下移动页面时,我希望它使其向右浮动(将内容悬停)。 最佳答案 使用 position 属性和 bottom、right 属
我正在使用 jtabbedpane,我正在尝试为选项卡设置一个关闭按钮,但不要丢失它所具有的标题! 注释: “GestorJanelas”是我的 JTabbedPane 字符串“titulo”是选项卡
是否有非 JSNI 方法可以向对话框的标题栏区域添加关闭按钮? 最佳答案 我们从项目一开始就使用了 GWT-ext。这是一个坏主意。他们有很多很酷的小部件,但它们不是 GWT 小部件,而且与 GWT
我正在尝试为以下机制找到解决方案: 我有一个底部播放器,它显示在所有页面上,角落里有一个“x”关闭按钮。每当我单击“X”时,播放器就会关闭,但如果我刷新页面,它会再次显示,我需要再次单击“X”才能隐藏
您好,我有一个 jFrame,我想问问用户他是否确定在单击关闭按钮时关闭 jframe: this.addWindowListener(new java.awt.event.WindowAda
我制作了一个 float 在屏幕中间的表单 为此我设计了一个关闭按钮 但我想在屏幕上的任何地方用鼠标点击关闭表单 我的代码 $(".offer-close").click(function ()
我正在尝试编写一个可以在同一行中多次放置的响应式按钮,并始终在包含该按钮的行下方显示其内容。 代码片段中有一个工作代码,但它有一个小缺陷:由于使用了伪类 focus,一旦按钮打开,点击屏幕上的任意位置
我正在开发一个适用于 OS X 的应用程序,在该应用程序中,我使用了一个自定义窗口,该窗口将图像绘制为背景,包括标题栏。我一直在修改this code绘制窗口,然后调用 [NSWindow stand
我正在使用 wxWidgets(C++ 版本)开发记事本应用程序,并且我正在努力实现多文件支持。使用 wxNotebook 类,我似乎找不到任何有关向页面添加关闭按钮的文档,因此我可以轻松关闭单个文件
我做了以下弹出窗口: https://jsfiddle.net/ca4h0a0q/ Click x This is your div content Javascript: $(
如何删除标记信息窗口中的“X”按钮? [ “美人鱼奥布里卡(原名:奥布里·亚历克西斯)”, 36.8618,-76.203, 5、 “迈克·欧文/乔治亚·梅森”, “USAVE汽车租赁”, “弗吉尼亚
我知道已经有问题问同样的问题,但是,我仍然没有运气在表单模态视图的角落实现“X”按钮。 在屏幕截图 HERE 中可以看到我正在尝试实现的一个完美示例。 . (如果 >= 10 代表的人可以通过在此处发
我正在尝试设置 WPF 窗口。 窗口应始终处于最大化状态 窗口不能移动或调整大小 它应该包含最小化和关闭按钮但不包含最大化按钮 我尝试了以下 XAML 代码 xaml 的输出是一个处于最大化状态的
当 fancybox 触发弹出窗口时,我想禁用关闭按钮,并在 x 秒后启用它。 有什么解决办法吗? 提前致谢。 最佳答案 这个很有趣。 如果您想隐藏关闭按钮以防止至少在 10 秒内关闭,您可能还想禁用
我正在 WPF 中创建一个基本的数据库应用程序,并且我已经开始使用 MVVM 模式。 我有一个对话框,要求用户从 ListBox 中选择一个项目,然后单击“确定”。之后,我将用户从 View 模型中的
如果“允许窗口管理器装饰窗口”已打开。wine 源中知道用户单击此 X 按钮并向应用程序发送 WM_CLOSE 的函数名称是什么?谢谢 最佳答案 窗口管理器发送类型为 WM_PROTOCOLS 且协议
在研究问题时,似乎大多数人都想做相反的事情(即删除最小化/关闭按钮)。我没有成功使用 reoccurrent setUndecorated 和 setDefaultCloseOperation 这是我
我正在使用 jqueryui 对话框,我想隐藏顶部的 X 按钮。 我试过下面的代码,但没有用。 $( '.ui-dialog-titlebar-close').remove(); 我的JS: $(f
我是一名优秀的程序员,十分优秀!