Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6612] iOS: Animation override not working correctly

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsanimation, ios
Reportermartin
AssigneeAbir Mukherjee
Created2020-10-01T23:20:25.000+0000
Updated2020-10-01T23:22:42.000+0000

Description

Overriding an animation on iOS sometimes does not work correctly. The following example, when tapping the window, should show a black view moving from left to right. When reaching about the middle of the screen, another animation should override the first and move the view back again. On Android it works as expected, on iOS the view pauses, jumps to the right side of the screen, animates a smal distance and finally jumps back to the left side of the screen.
const win=Ti.UI.createWindow({
	backgroundColor:'white'
});
 
const view=Ti.UI.createView({
	left:0,
	width:100,
	height:100,
	backgroundColor:'black',
	overrideCurrentAnimation:true //this is for Android
});
win.add(view); 
 
const animate=(forward,duration)=>{
	view.animate({
		left:forward ? win.size.width-view.size.width : 0,
		curve:Ti.UI.ANIMATION_CURVE_LINEAR,
		duration:duration	
	});
};
  
const button=Ti.UI.createButton({
	title:'Start',
	bottom:100
});
button.addEventListener('click',()=>{
	animate(true,2000); //animate the view from left to right with a duration of 2000 ms...
	setTimeout(()=>animate(false,2000),1000); //... but after 1000 ms we override to animate back again
});
win.add(button); 

win.open();

Comments

No comments

JSON Source