Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to not repositionning elements? #20

Open
iacuzzoGiovanni opened this issue Feb 25, 2013 · 1 comment
Open

How to not repositionning elements? #20

iacuzzoGiovanni opened this issue Feb 25, 2013 · 1 comment

Comments

@iacuzzoGiovanni
Copy link

I would like to move items from their position I defined in relative and not in a redefined position. Is there a way to do that? I'll be grateful if you could help me :-)

@beldar
Copy link

beldar commented May 14, 2013

Hi, I faced this problem too, with a little bit more personalization I came up with this SineWave function:

var SineWave = function($el) {
    this.offsety = $el.offset().top;
    this.offsetx = $el.offset().left;
    this.direction = -1; //-1 for left to right, 1 for right to left
    this.amplitude = 300;
    this.frequency = 10;
    this.css = function(p) {
      var s = Math.sin(p*20);
      var x = this.direction * p * this.amplitude + this.offsetx; 
      var y = s * this.frequency + this.offsety;
      return {top: y + "px", left: x + "px"};
    } 
  };
$("#element").animate({path : new SineWave($("#element"))},5000, "linear");

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants