jquery-animate

jQuery $.animate() multiple elements but only fire callback once

只愿长相守 提交于 2019-11-26 18:44:37
If you select a class or collection of elements to animate with jQuery: $('.myElems').animate({....}); And then also use the callback function, you end up with a lot of unneccessary animate() calls. var i=1; $('.myElems').animate({width:'200px'}, 200, function(){ //do something else $('#someOtherElem').animate({opacity:'1'}, 300, function(){ if (i>1) console.log('the '+i+'-th waste of resources just finished wasting your resources'); i++; }); }); Arguably this is just bad code and / or design - but is there something I can do that both avoids having many animate() calls with only one of them

Call Scroll only when user scrolls, not when animate()

谁说我不能喝 提交于 2019-11-26 18:27:08
问题 I have a few links across the page with the purpose of "going to the top", accomplished by scrolling the page to the top with a nice animation. I've noticed that sometimes while the page is scrolling the user will want to scroll back down, for example, but this is not possible. The screen will only stutter but will continue animating until it reaches the top. I want to stop the animation if the user attempts to scroll, therefore I wrote this code: $('#gototop').click(function() { $('body')

Does jQuery have a plugin to display a “message bar” like the Twitter “wrong password” bar at the top of screen?

非 Y 不嫁゛ 提交于 2019-11-26 18:16:35
问题 Twitter will pop down a message bar at the top of the screen say "Wrong password" and after 10 seconds, it will slide up and disappear. Chrome also shows "Do you want to save the password" message box using such a way. Does jQuery have a plug in to do that already? Does it also work in IE 6? Because usually, the display of relative to the viewport (using position: fixed ) will not work on IE 6. thanks. Update: thanks for the nice solutions -- I deliberately wanted it to work (1) even when the

Jquery/Javascript Opacity animation with scroll

瘦欲@ 提交于 2019-11-26 18:12:01
问题 I'm looking to change the opacity on an object (and have the transition be animated) based on a users scroll. example(http://davegamache.com/) I've searched everywhere like here, but it ends up pointing me to the waypoints plugin (http://stackoverflow.com/questions/6316757/opacity-based-on-scroll-position) I've implemented the [waypoints][1] plugin and have the object fading once it's higher than 100px. [Using the offet attribute] but would like to basically control the opacity of an object

Scroll smoothly to specific element on page

风格不统一 提交于 2019-11-26 17:20:17
I want to have 4 buttons/links on the beginning of the page, and under them the content. On the buttons I put this code: <a href="#idElement1">Scroll to element 1</a> <a href="#idElement2">Scroll to element 2</a> <a href="#idElement3">Scroll to element 3</a> <a href="#idElement4">Scroll to element 4</a> And under links there will be content: <h2 id="idElement1">Element1</h2> content.... <h2 id="idElement2">Element2</h2> content.... <h2 id="idElement3">Element3</h2> content.... <h2 id="idElement4">Element4</h2> content.... It is working now, but cannot make it look more smooth. I used this code

jquery.animate background-position doesn't work

北战南征 提交于 2019-11-26 17:08:11
问题 I'm trying to create a background position change with animation. but for some reason it's not working. <script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script> <div class="moveme" style="height:80px;width:240px;background-image:url('http://www.google.de/intl/en_com/images/srpr/logo1w.png');background-repeat:no-repeat"></div> <script language="javascript"> $('.moveme').css("background-position","0px 0px").animate({backgroundPosition:"-100px 10px"}); </script>

jQuery delay() - how to stop it?

落爺英雄遲暮 提交于 2019-11-26 16:49:53
问题 I already tried stop(true,true), stop(true) and clearQueue(); but this doesn't work. I have problem with fast changing slides, i already have some function what have to reset everything, but it doesn't work. function reset(){ $('div').clearQueue(); $('#img').html('').css({'left':0,'right':0,'opacity':1,'z-index':1}); $('#img2').html('').css({'left':0,'right':0,'opacity':1,'z-index':1}); $('#place').html('');$('#place').html('<div id="img"></div><div id="img2"></div>'); } But i thing this

How to make a jquery infinite animation?

。_饼干妹妹 提交于 2019-11-26 15:24:17
I'm trying to implement a jQuery function with an infinite loop to animate the body background with 3 colours. I cannot think of a nice and clean solution. Something like this? $(document).ready(function(){ $('body').animate({backgroundColor:'#ffcc00'}, 500, function(){ $('body').animate({backgroundColor:'#eeeeee'}, 500, function(){ $('body').animate({backgroundColor:'#3b5998'}, 500); }); }); }); Any idea? Diodeus - James MacFarlane You can eliminate the nesting, but the solution is a little fatter: var cols = "#ffcc00,#eeeeee,#3b5998".split(",") var cPos = 0 $(document).ready(function() {

jQuery 1.6: backgroundPosition vs backgroundPositionX and FF4 compatibility

穿精又带淫゛_ 提交于 2019-11-26 14:48:11
问题 In an attempt to upgrade the jQuery plugin 'iCheckbox' (http://stackoverflow.com/questions/6032538/) to work above jQuery 1.4.4 I found out that the use of animate({backgroundPosition:'10px 0px'}) needed to be changed to animate({backgroundPositionX: '10px', backgroundPositionY: '0px'}) as only properties with one parameter should be used. So far, this makes sense, but wait.. while it's working fine in Safari and Chrome, it's not working in FF4 (all on Mac).. So i tried this and that and

jQuery animate and property values in percentage

喜你入骨 提交于 2019-11-26 14:45:03
问题 I trying to animate a div and I try to use some value retreived somewhere else, I know the value to be correct because I've printed out the output... so I'm wondering why doesn't it work properly? animateBar(percentage.toFixed(2)+'%'); [ . . . ] function animateBar(percentage) { $('#innerBox').animate({width: percentage}, 3000); } 回答1: It seems as though theres a bug with using a percentage with animate. http://bugs.jquery.com/ticket/10669 I would suggest calculating the number of pixels to