-
I have to animate the text, like marquee tags. I am using this code, but there is strange behavior. The text initially scrolls slowly, then speeds up, and then slows down again. Have any ideas or suggestions? var win = Ti.UI.createWindow({
backgroundColor: "white"
});
var view = Ti.UI.createView({
top: 50,
height: 60,
backgroundColor: 'red'
});
var label = Ti.UI.createLabel({
color: 'white',
left: 0,
height: 20,
width: Ti.UI.SIZE,
text: "Lorem ipsum dolor sit amet, consectetur adipisci elit, sed do eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem ullamco laboriosam, nisi ut aliquid ex ea commodi consequatur.",
font: {
fontSize: '18sp',
fontWeight: 'bold'
}
});
// Text animation
function animateText() {
var width = label.toImage().width / Ti.Platform.displayCaps.logicalDensityFactor;
label.left = Ti.Platform.displayCaps.platformWidth;
label.width = width;
var animation = Titanium.UI.createAnimation({
left: -width,
duration: width * 30, // Otherwise short texts run too fast and long texts slowly
repeat: 100,
});
label.animate(animation);
};
view.add(label);
win.add(view);
win.open();
animateText(); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This solves the problem: var animation = Titanium.UI.createAnimation({
left: -width,
duration: width * 30, // Otherwise short texts run too fast and long texts slowly
repeat: 100,
curve: Titanium.UI.ANIMATION_CURVE_LINEAR
}); Thanks to @m1ga for the suggestion! |
Beta Was this translation helpful? Give feedback.
-
If you are interested in a more functional text animation, @macCesar has created this fantastic library: https://github.com/macCesar/ti.scroller |
Beta Was this translation helpful? Give feedback.
This solves the problem:
curve: Titanium.UI.ANIMATION_CURVE_LINEAR
, and soThanks to @m1ga for the suggestion!