Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ken Burns effect with nivo slider

Has anyone set up a nivo slider to pan each image (aka Ken Burns effect)? I'm trying to implement it and it's kinda tricky!

like image 972
nnyby Avatar asked Oct 09 '22 19:10

nnyby


1 Answers

Actually, I got my implementation working!

I have a panning function loop.. something like this:

function ken_burns_loop(el) {
  $(el)
    .animate({
      'background-position-x': '40%',
      'background-position-y': '60%'
    }, 8000, 'linear')
    .animate({
      'background-position-x': '30%',
      'background-position-y': '40%'
    }, 8000, 'linear')
    .animate({
      'background-position-x': '70%',
      'background-position-y': '70%'
    }, 8000, 'linear', function() { ken_burns_loop(el); });
}

And I'm initializing nivo slider like this:

$('#welcome-slider').nivoSlider({
  effect: 'fade',
  slices: 1,
  directionNav: false,
  afterChange: function() {
    $('#welcome-slider, .nivo-slice').stop(true);
    ken_burns_loop('#welcome-slider, .nivo-slice');
  }
});
ken_burns_loop('#welcome-slider, .nivo-slice');

I'm still working out some problems with positioning.

like image 170
nnyby Avatar answered Oct 13 '22 12:10

nnyby