This is pertaining to an image gallery, so as you "swipe", images are loaded and unloaded off of the screen, but the center image always appears smoothly.
It is code derived from the swipeview library described here: http://cubiq.org/swipeview
The problem is that, there is a 100-200ms delay which occurs between when the javascript sets the webkitTransform in the touch end event, and when the element actually starts animating on the screen.
This problematic delay, only happens intermittently; it seems that it starts happening consistently after about 15-20 slides have been unloaded/loaded.
In the touch move event there is code like this:
element.style.webkitTransitionDuration = 0
element.style.webkitTransform = "translate3d( etc. ) "
And this functions very fast, such that if you move your finger around on the ipad, the element follows your finger precisely and "instantly".
And in the touch end event there is code like this:
element.style.webkitTransitionDuration = '<some_number>ms';
element.style.webkitTransform = "translate3d( etc. ) "
And the touch end event is where the problem is. The touch End event itself fires the instant the finger is removed from the ipad, however, when the problem is happening, the css update doesnt trigger an actual animation on screen until after the problematic delay mentioned above.
This was a tricky one. I finally found the culprit. In my touchend event listener, I was calling a function that added classes to DOM elements. This caused Safari to take a moment to rewire textures to the GPU, resulting in the stutter. Removing those direct className updates made it all buttery smooth again (and I'm still using requestAnimationFrame and not CSS transitions).
I moved my className changes to a separate event that fired from touchend instead and it didn't cause any performance issues. So, if you must set classes, just don't do it directly in the touchend callback. Trigger another event instead or set the classes in requestAnimationFrame.
Related
So I'm making a sort of spleef type game where players jump around as blocks disappear beneath them. However, if you just hold down the space bar, Roblox doesn't seem to register the "Touched" event. Can anyone help?
Here is my script for each of the disappearing platforms:
local platform = script.Parent
local function fade()
print("Touched!")
platform.Transparency = 1
platform.CanCollide = false
end
platform.OnTouched:Connect(fade)
A BasePart doesn't have an event named "OnTouched", but I think you are referring to "Touched" event of BasePart.
You can change the platform.OnTouched:Connect(fade) to platform.Touched:Connect(fade)
https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched
With new r15 anthro models, sometimes the touch won't register as the hitbox fails to register a touch.
What I did a long ago was to create an invisible box with no collision that is thin above the part that you would like to touch, then check the .Touched event in the invisible box instead the one you are checking right now.
I'm working on the RN application that has one screen with a list of "drawable" areas in it. So this screen should be scrollable AND drawable.
What I'm trying to do - is to find a solution to distinguish touch events coming from fingers (these will be used to scroll and disallow drawing) and stylus via Apple Pencil (these will be used to draw and disallow scrolling).
In both Gesture Responder and PanResponder there are events being passed on each move. Each of those events (alongside with the nativeEvent) contains the type property. However, it's always null for me in both simulator and device.
Is there any way to recognize a move event as a finger vs stylus?
We had a similar requirement for one of our projects, and what we did was to use a Pressable component, to which a handlePress function was passed as prop.
This function accepted the GestureResponderEvent as event callback argument.
By using the event.nativeEvent.altitudeAngle property that was added recently, we were able to detect Apple Pencil touches.
function handlePress(event: GestureResponderEvent) {
//#ts-expect-error React Native Types do not include altitudeAngle
const isPencilTouch = !!event.nativeEvent.altitudeAngle;
...
}
We're using Appium with iOS Simulator and test functions written in Java.
We have an iOS App with screen 1 containing a UICollection view, and tell Appium to click on one of its elements.
This opens screen 2 (and the scrolling animation takes about 500 ms), which also contains an UICollection view. I want to find out the size of the UICollection view of the second screen with Appium.
The problem is that Appium is too fast and executes the findElements() method directly after the click, which causes it to find the UICollection view of the first screen.
clickOnElementOnFirstScreen();
webDriver.findElements( By.className( "UIACollectionCell" ) ).size();
// is supposed to find the UICollection view on the second screen,
// but actually finds the UICollection view on the first screen
Appium provides several waiting functions. However as far as I can see all of them are intended to be used in this fashion:
"wait until element at location X / with name X becomes visible"
If I try to use these waiting functions, they don't wait at all because they immediately find the UICollection view of the first screen, which has the same location and name as the one on the second screen.
The only solution I have found is to use Thread.sleep:
Thread.sleep(1000);
webDriver.findElements( By.className( "UIACollectionCell" ) ).size();
But we don't want to use Thread.sleep in code that will run on the client's server on hundreds of tests.
We might be able to modify the App and enter metadata into the views so that Appium is able to distinguish them, but this situation occurs in several places and the App is being programmed by the client, so we want to avoid this too.
What is a simple and safe way to wait for the new screen to appear, without modifying the code of the iOS App?
I have found only dirty workaround for this issue.
static waitFor(Duration duration) {
try {
def WebDriverWait wait = new WebDriverWait(mobileDriver, duration.standardSeconds)
wait.until(visibilityOfElementLocated(By.xpath("//Fail")))
//Wait until false case is visible to ensure proper timeout
} catch (Exception e) {
}
}
Another workaround/solution that has been posted on the Appium forums is:
First search for some other element that distinguishes the 2. screen from the 1. screen; once that is visible, it's safe to search for the originally desired element.
I have been suffering from a bug for sometime:
I am doing something like the following:
$container.on('touchmove', function(){
$container.trigger( 'lazyload.appear');
});
$img.one( 'lazyload.appear', function(){
var that= this;
var $self= $(that);
$self.css('background-image', "url('real.path.to.img')" );
});
However, on IOS there seems to be a problem with repainting the background-images, when they are initially outside the viewport. When I drag my finger, until the image is in the viewport, the images aren't painted onto the screen unless i release my finger. I'm trying to aim for real-time, so I would like the image to be revealed as soon as I do a touchmove, but its being revealed at touchend when its initially outside the viewport. However, the console.log outputs that the background-image has changed before releasing my finger. When the image is inside the viewport, the repainting is fine, it repaints instantly as I drag my finger.
This seems to be a bug, or am I missing something? Thank you for your help!
I am using a parallax effect with javascript but I'm having issues with iPad.
I know the "$(window).scroll" is not triggered on webkit touch devides - only when we release the screen - so i'm using:
window.addEventListener("touchmove", triggerScroll, false);
function triggerScroll(event)
{
var scrollTop = $(window).scrollTop();//event.touches[0].pageY; //window.pageYOffset();
$("#allCanvas .divCanvas").each(function(index, element) {
var speed = $(element).data('speed');
var initialTop = $(element).data('initialtop');
$(element).css('top', initialTop-(scrollTop*speed));
});
}
The problem is that it flickers the .divCancas a few pixels to the top or bottom depending if I'm scrolling to top or down.
I tracked the TOP value passed on $(element).css('top', initialTop-(scrollTop*speed)); and it's every time correct. The correct "TOP" value, eventhough webkit move it for a few milleseconds to the wrong position.
I tried also:
-"margin-top" rather than "top" with no difference.
-Removing all other objects and making the ".each" loop through only one div, so I guess is not a jQuery performance issue.
Has anyone came across this problem?
Many thanks
Diego
Maybe try using some of the -webkit css animation features... these run very smoothly on iOS devices. Here's a great demo of that (webkit only): http://jibjub.com/demo/HTML5/cube.html