How to hide "VR" button unless VR headset is present on A-Frame scene - aframe

By default an A-Frame scene shows a "VR" icon to enter immersive VR mode in all cases, even if a headset is not present. Is there a simple way to only show this icon when a user is using a headset with WebXR available?

Yes, there is a built in A-Frame function checkHeadsetConnected() for this purpose. You can use this in a component attached to the a-scene entity to disable vr-mode-ui when a headset is not present. Here is example code for this:
// only show VR button if headset connected
AFRAME.registerComponent('vr-mode-ui-if-headset', {
dependencies: ['vr-mode-ui'],
init: function () {
if (!AFRAME.utils.device.checkHeadsetConnected()) {
this.el.setAttribute('vr-mode-ui', 'enabled', false);
}
}
})
Here is a glitch A-Frame scene showing this component in use:
Code: https://glitch.com/edit/#!/lapis-wide-cartoon?path=index.html
Live project: https://lapis-wide-cartoon.glitch.me/

Related

How to control scrolling of component in React?

I have 4 main components for my React portfolio site called Home, Portfolio, About, Contact. The components are linked in Navigation. If I click on those link, Component appears. But the problem is if I scroll the Portfolio page 50% and click on About. The About page stay automatically scrolled top by 50%. I don't want an automated scroll. Rather I want the component will start from top 0;
I have tried "css-snap-type" but it doesn't work.
How can I solve the problem?
you could solve this using a react component that will scroll the window up everytime you click on a different link.
checkout this documentation is pretty straight forward https://reactrouter.com/web/guides/scroll-restoration
If you are using gatsby it comes with and API called called shouldUpdateScroll you could implement it on the gatsby.browser.js
const transitionDelay= 500
exports.shouldUpdateScroll = ({
routerProps: { location }, //location
getSavedScrollPosition, //last position on the previous page
}) => {
if(location.action === 'PUSH'){
window.setTimeout(()=> window.scrollTo (0,0), transitionDelay)
}
else {
const savedPosition = getSavedScrollPosition(location)
window.setTimeout(
()=> window.scrollTo((savedPosition || [0,0])),
transitionDelay
)
}
return false
}
U need to set window.scrollTo(0, 0) when u click on link so it would start on top of page.

JavaFx Repaint Canvas on StyleCssClass Change

To change the stylesheet to a dark one in my code I execute in Scene :
getStylesheets().add(FxFrame.class.getResource("/css/dark.css").toExternalForm())
This works fine.
I also have a canvas where some colors are configured using:
final StyleablePropertyFactory<FxDrawCanvas> FACTORY = new StyleablePropertyFactory<FxDrawCanvas>(FxDrawCanvas.getClassCssMetaData());
StyleableProperty<Color> calloutBackground1Color = FACTORY.createStyleableColorProperty(FxDrawCanvas.this, "callout-background1-color", "callout-background1-color", s -> s.calloutBackground1Color, Color.web("0xffffff" ));
The canvas should be repainted when the stylesheet css gets changed. How may I make the canvas aware of scene css change ?
Is possible to listen on css stylesheet changes in the canvas ?
Or fire any event in the scene which the canvas can intercept ?

Link with hover overlay is opened on first click on mobile device

I have a div that displays another content on hover using css transitions.
There is one text element <h3>Another Text</h3> that overlays link email adress. On desktop browser it's working correctly - I can click the link after hover is activated. On phone device where hover is replaced by clicking on the element, there's a problem - If I activate the hover by clicking on "Another Text" it opens the link right away.
My question is if there is any way how to restrict link opening on first click.
Ideal scenario on phone device is:
user clicks on "Another text"
hover is activated, link is displayedbut not fired
user click link and link is fired
Here is the code: https://jsfiddle.net/9bc0bcja/2/
I've partially solved it using javscript:
$(".team-social")
.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",
function(e){
if($(this).hasClass("pointerA")){
if(is_touch_device()){
$(this).removeClass( "pointerA" );
}
}
else{
$(this).addClass( "pointerA" );
}
});
$('.team-social a').click(function() {
if(is_touch_device()){
$(this).parent().removeClass("pointerA");
}
});
It activates pointer-events after transition finishes, so it is not fired right away when I click overlay on phone device.
https://jsfiddle.net/9bc0bcja/4/
added javascript + jquery link
added class .pointerA
added pointer-events:none; to class .team-social
Try this Fiddle.
I simplified your code, keeping only the necessary elements.
This script only operates if you're using a mobile device, which is what you should want for performance reasons.
This code watches the hover event rather than transitionEnd, that way the function trigger timing is not dependent on the length of the transition.
if (is_touch_device()) {
var $wrap = $(".wrap"),
$pw = $wrap.find(".pointer-watch"),
$tc = $pw.find(".transition-container");
$pw.addClass("pointerN");
$('.wrap').hover(function wrapHovered() {
if ($pw.hasClass("pointerN")){
setTimeout(function enablePE() {
$pw.removeClass("pointerN");
}, 0);
}
else if (!$wrap.is(":hover")) {
$pw.addClass("pointerN");
}
});
}

Replace default play button on Brightcove's Smart Player on mobile devices

Quite likely I just need the right terms to find the answer; however, I imagine someone else has already encountered this problem and knows right away how to solve it.
I'm using Brightcove's services and their Smart Player. I've configured a Chromeless player and tried to eliminate ALL controls because my page's controls will use their API to play, pause, etc. On desktop, this works just ok. On mobile devices (iOS7 Safari) there is a play button overlay on the video player that I'd like to replace with my own graphic.
I'd like to turn this:
into this:
Anyone know how to do this? I can't just reach into the player with JavaScript because it's in an iframe filled by Brightcove services.
You can do this with a javascript player plugin, which runs inside the player iframe. Use the overlay API to create your custom play button and playOverlayCallbacks() to prevent the default play overlay from being displayed.
Something like this would work in a plugin:
(function() {
function addPlayOverlay() {
var overlay = videoPlayer.overlay();
$(overlay).css('background', 'transparent url("http://example.com/playbutton.png") no-repeat center center')
.width($(document).width())
.height($(document).height())
.css("-webkit-box-shadow","inset 0 0 150px rgba(0,0,0,0.9)")
;
$(overlay).click(function(){
// Play when custom overlay is clicked
videoPlayer.play();
});
videoPlayer.playOverlayCallbacks({
show: function() {
// Show custom overlay
$(overlay).fadeIn();
// Prevent standard play overlay
return false;
},
hide: function() {
// Hide play overlay
$(overlay).fadeOut();
return false;
}
});
}
var
bcplayer = brightcove.api.getExperience(),
videoPlayer = bcplayer.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER),
experience = bcplayer.getModule(brightcove.api.modules.APIModules.EXPERIENCE);;
if (experience.getReady()) {
addPlayOverlay();
} else {
experience.addEventListener(brightcove.player.events.ExperienceEvent.TEMPLATE_READY, addPlayOverlay);
}
}());

QT/C++ on MAC - How do I hide my dock icon?

I'd like my dock icon to be hidden and the app to be represented as a menu bearing icon on the menu bar (right hand side).
This will hide the icon:
http://www.macosxtips.co.uk/index_files/disable-the-dock-icon-for-any-application.html
Summarizing the URL, in the dict xml element inside Info.plist in the app, add the lines:
<key>LSUIElement</key>
<string>1</string>
You need to use the appropriate OS APIs to add the menu.
The alternative answer is by using TransformProcessType() to show/hide dock icon dynamically in code.
#import <Foundation/Foundation.h>
void toggleDockIcon(bool show) {
ProcessSerialNumber psn = {0, kCurrentProcess};
if (show) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
} else {
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
}
}

Resources