I wonder what's wrong. In emulated chrome touch, it worked perfectly. In mobile compiled to JavaScript chrome browser, does not work perfectly.
*Tested on Android 4.1 - Chrome 30 - dual core
Dart Editor version 0.8.1_r28355
Dart SDK version 0.8.1.2_r28355*
import 'dart:html';
DivElement divContainer;
void main() {
divContainer = new DivElement()
..style.backgroundColor = '#6a00d7'
..style.width = '600px'
..style.height = '600px';
document.body.nodes.add(divContainer);
window.onTouchMove.listen((event) => mov(event));
}
mov(evento){
divContainer.innerHtml = evento.touches[0].client.x.toString();
}
Add inside the method call:
event.preventDefault();
Prevents shortcuts "touch" interfere (chrome mobile).
Method code:
mov(evento){
evento.preventDefault();
divContainer.innerHtml = evento.touches[0].client.x.toString();
}
Related
I am using the native camera (iOS/Android) calling as following:
async function takePhoto() {
const photo = await ImagePicker.launchCameraAsync(cameraOptions);
if (photo.cancelled) {
return '';
}
return photo.uri;
}
Since upgraded from Expo 39 to 42 it is broken (see screenshots)
Portrait
Landscape
It seems to me, that it is beeing opened as Modal. I don't know where to change this.
Expected behaviour:
Display of camera in fullscreen as native camera under iOS
Update: 20210730: Meanwhile it has been opend as a bug/issue:
https://github.com/expo/expo/issues/13614
Any ideas, suggestions - especially in terms of a workaround?
Thanks a lot.
I've done a massive upgrade from EXPO SDK 37 to EXPO SDK 42. Had to change alot of things around camera, location and permissions.
I do not experience this behavior when using the following (I cannot see your import statements or your package versions but this is what I've implemented and experience no issue)
// Import statements...
import * as ImagePicker from 'expo-image-picker';
import * as FileSystem from 'expo-file-system';
import { Camera } from 'expo-camera';
// Code within Component
const takePicture = async () => {
// You MUST ask for permissions first.
const permissions = {
[Camera]: await Camera.requestPermissionsAsync()
};
// If denied let the user know its required.
if (permissions[Camera].status !== 'granted') {
return Promise.reject(new Error('Camera Permission Required'));
}
// Then let them launch the camera and perform any other task
await ImagePicker.launchCameraAsync({
allowsEditing: false
})
.then(({ uri }) => imageProcesser(uri))
.then(res => onImageAdded(res))
.catch((e) => console.log(e));
};
// These are my concerning package versions
"expo-camera": "^11.2.2"
"expo-file-system": "~11.1.3",
"expo-image-picker": "~10.2.2",
"expo": "^42.0.3"
I am programming an app in Ionic and using hammer.js for the pan gesture (for the moment, only this one). In the browser (chrome and safari) this is working fine, also on Android device, but I just discovered that pan gesture is not working on iOS (neither real device nor emulator). After a long while research, I don't find the way to make it work. Neither pan nor panend work (click does).
Note: The events are (should be) launched from a custom component, not a page itself.
I have seen other with similar problems, but no solution that works for me. Here is finally stated that hammerjs it not so compatible with iOS, but here says it it. This guy seems to have a similar problem, but found no solution.
I have also try adding to my app.module.ts the following code and the provider {provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig}. No success.
import * as Hammer from 'hammerjs';
import {HammerGestureConfig, HAMMER_GESTURE_CONFIG} from '#angular/platform-browser';
export class MyHammerConfig extends HammerGestureConfig {
overrides = <any> {
'pan': {
enable: true,
direction: Hammer.DIRECTION_HORIZONTAL
}
};
}
Hier is (an extract of) my code:
export class SeekbarQuantizedComponent implements OnInit, OnChanges {
private stepsPositions: number[]; // Will have the position of the different steps (in %)
private progress = 0; // The progress of the progressbar in %
[...]
onClick($event: MouseEvent) {
const clickX = $event.offsetX * 100 / this.background.nativeElement.offsetWidth;
this.setProgress(clickX);
this.valueSelected.emit(this.selectedPosition);
}
onPan($event) {
this.setProgress(100 * ($event.changedPointers[0].offsetX / this.background.nativeElement.offsetWidth));
}
onPanEnd($event) {
this.setProgress(100 * ($event.changedPointers[0].offsetX / this.background.nativeElement.offsetWidth));
this.valueSelected.emit(this.selectedPosition);
}
[...]
}
The html:
<div #background class="progress-outer"
(click)="onClick($event)"
(pan)="onPan($event)"
(panend)="onPanEnd($event)">
<div class="progress-inner"
[style.width]="progress + '%'">
{{text}}
</div>
</div>
Is there a way to create a headless WebView instance in Nativescript (Vue) for use with nativescript-webview-interface (which expects a Nativescript view)? How can I instantiate the Vue component so it creates the native webview in the background (similar to document.createElement on web)?
Try the core way of creating elements
import { WebView } from "tns-core-modules/ui/web-view";
...
methods: {
createWebView: function() {
const webView = new WebView();
// Remember to pass in context in case of android
wv._setupAsRootView({});
wv.onLoaded();
...
}
}
...
I am developing an IOS app using Adobe AIR, Flash and ActionScript 3 and I have divided sections up into separate SWF files. I have successfully gotten the app to load external SWFs and execute their ActionScript using the following code:
var proloader:ProLoader = new ProLoader();
proloader.load(new URLRequest("file.swf"), new LoaderContext(false, ApplicationDomain.currentDomain, null));
addChild(proloader);
Now, I would like to add a reset button that allows the user to return to the start of the first SWF from any other SWF file to restart the app. Unfortunately, it seems that whenever I try to load a SWF that has previously been loaded, nothing happens. I have read that unloading and reloading SWFs is not permitted on IOS and the fact that you are limited to one ApplicationDomain on IOS makes things difficult. However, I am still thinking there must be some workaround. I'd be okay with not ever unloading the external SWFs if that is the only way, but I still can't figure out a way to return to a SWF that was previously loaded.
Does anyone know of a way to return to a SWF that was previously loaded in IOS with Adobe Air?
You could have a static class that functions as a cache.
The cache might look something like this that I made for a menu system:
package com.rs2014.managers{
import flash.display.MovieClip;
import flash.utils.Dictionary;
import flash.events.Event;
import flash.events.EventDispatcher;
import com.events.MenuManagerEvent;
import com.menus.MenuBase;
import com.components.MenuLoader;
import com.MenuIdents;
public class MenuManager extends EventDispatcher
{
private static var instance:MenuManager
private static var allowInstantiation:Boolean = true;
public static function getInstance():MenuManager
{
if(!instance)
{
instance = new MenuManager();
allowInstantiation = false;
}
return instance
}
private const MAX_MENUS:uint = 8;
private var menuCache:Dictionary = new Dictionary()
public function MenuManager()
{
if(!allowInstantiation)
{
throw(new Error("please use the getInstance() method to obtain a handle to this singleton"));
}
}
public function getMenu(menu:String):void
{
if(menuCache[menu])
{
//This pulls from the cache if it's already been loaded before
dispatchMenu(null, menuCache[menu]);
}
else
{
//MenuLoader is a simple wrapper for Loader
var newLoader:MenuLoader = new MenuLoader();
menuCache[menu] = newLoader;
newLoader.addEventListener(Event.COMPLETE, dispatchMenu);
newLoader.source = menu;
//trace("setting up loader with source = "+menu);
}
}
private function dispatchMenu(e:Event = null, menu:MenuBase = null):void
{
if(e)
{
e.target.removeEventListener(Event.COMPLETE, dispatchMenu);
//trace(e.target.content);
//trace(e.target.content as MenuBase);
menuCache[e.target.source] = menu = e.target.content as MenuBase;
//trace(menu);
}
if(!menu)
{
throw(new Error("MenuManager Error: dispatchMenu called without menu to dispatch"));
}
this.dispatchEvent(new MenuManagerEvent(MenuManagerEvent.MENU_READY, menu))
}
}
}
I was able to solve the problem of reloading SWF's w/o ABC (no code!), I explain it all on my blog (http://www.eqsim.com/blog/?p=400) but also simply give the code on StackOverflow: Load and reload external SWF in AIR for iOS wf-in-air-for-ios/22046009#22046009
Now Adobe has a solution for separating code from the SWF, and loading the SWF externally. However, we addressed it prior to AIR 3.5 by making a class for the code only, then loading the SWF and in the code class, setting a link to the loaded SWF. When we needed to update to 4.0, the SWF reloading, even pure SWF assets, was not working in all situations, so we plugged away to find the solution I reference above.
I am having a great deal of difficulty getting the childBrowser plugin to work
Currently when I click my link it does nothing on my iOS simulator and when I click it using a browser I get a Web Page Not Found error with the web address looking something like:
file://myapp/www/%C3%A2%E2%82%AC%C2%9D#ᅢᄁ¬ツᆲᅡン
I am really stuck for ideas on whats going on and what is causing this, any advice would be greatly appreciated.
My code is:
<script type="text/javascript" charset="utf-8" src="js/ChildBrowser.js"></script>
<script>
function onDeviceReady() {
childbrowser = ChildBrowser.install();
var root = this;
cb = window.plugins.childBrowser;
if(cb != null) {
cb.onLocationChange = function(loc){ root.locChanged(loc); };
cb.onClose = function(){root.onCloseBrowser(); };
cb.onOpenExternal = function(){root.onOpenExternal(); };
//cb.showWebPage(“http://google.com”);
}
}
function onCloseBrowser() {
console.log(“onCloseBrowser!”);
}
function locChanged(loc) {
console.log(“locChanged!”);
}
function onOpenExternal() {
alert(“onOpenExternal!”);
}
<body onLoad=”onBodyLoad()”>
<a href=”#” onclick=’cb.showWebPage(“http://www.google.com”);’>Click Me</a>
It is difficult to get which part of the app is doing wrong as given source is not enough. I have a small demo application which just uses childbrowser with cordova 1.7.0 which you can check to make sure the source is unaltered.
ios-cordova-childbrowser example