Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Animating a view...

I'm trying to animate a view to move to the right 100px and down 100px. Unfortuantly, nothing happens when I fire the event I'm listening for. Any help would be appreciated!


// Add a default color to show when nothing is open
Titanium.UI.setBackgroundColor('#000');

// Create a view with a pleasing background color
var window = Titanium.UI.createWindow({
  backgroundColor:'#0F0F1F',
  exitOnClose: true
});

// Create a view to animate
var view = Titanium.UI.createView({
  top: 0,
  left: 0,
  borderRadius:10,
  backgroundColor:'red',
  width:50,
  height:50
});
window.add(view);// Add the view to the window

// Create the event listener that will call my animation
view.addEventListener('click', function()
  {
    // Start the animation when the event is called
    view.animate(
    {
      right:100,
      top:100,
      duration:500});
    });

// Create a text label to provide instructions
var label = Titanium.UI.createLabel(
  {
    text:'Click to animate',
    bottom:75,
    width:'auto',
    height:'auto',
    textAlign:'center'
  });
window.add(label);// Add the label to the window

window.open({fullscreen:true});// Open the window
— asked October 30th 2010 by Jason E. Gyurkovitz
  • android
  • animation
  • titanium mobile
  • view
0 Comments

1 Answer

  • Accepted Answer

    down, does not exist : try to modify the top value

    view.animate(
    {
    right:100,
    top:100,
    duration:500});
    });

    — answered October 30th 2010 by Stephane Pelamourgues
    permalink
    2 Comments
    • Still nothing, thanks for trying.

      — commented October 30th 2010 by Jason E. Gyurkovitz
    • I don't think 'view' is accessible in the function passed into the event handler. Try 'this':

      this.animate(
          {
            right:100,
            top:100,
            duration:500});
          });
      

      — commented January 24th 2012 by Chris K
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.