jquery-animate

Implementing jQuery's shake effect with animate

馋奶兔 提交于 2019-11-28 20:43:29
I've been given a cut down subset of the jQuery lib one of the key features I'm missing is the .effect functions. I do however have .animate . I was wondering if anyone would have any ideas how I could go about reproducing the animation functions. I am particularly consious of making this only a few lines as I need to keep the code size down. Which is why the jquery lib is as small as it is and doesnt have the effects functions. TLDR - I'm trying to replace $("#"+id_string).effect( "shake", {}, "fast" ); With something using .animate within jQuery. It's actually already implemented this way

Animating inline elements with jQuery

帅比萌擦擦* 提交于 2019-11-28 20:26:34
I am trying to show and hide an inline element (eg a span) using jQuery. If I just use toggle(), it works as expected but if I use toggle("slow") to give it an animation, it turns the span into a block element and therefore inserts breaks. Is animation possible with inline elements? I would prefer a smooth sliding if possible, rather than a fade in. <script type="text/javascript"> $(function(){ $('.toggle').click(function() { $('.hide').toggle("slow") }); }); </script> <p>Hello <span class="hide">there</span> jquery</p> <button class="toggle">Toggle</button> toggle() has a bunch of weird

How to animate CSS Translate

雨燕双飞 提交于 2019-11-28 19:16:02
Is it possible to animate the CSS property translate via jquery? $('.myButtons').animate({"transform":"translate(50px,100px)"}) and does it work in many browsers? Demo not working: http://jsfiddle.net/ignaciocorreia/xWCVf/ UPDATE: My solutions: Simple implementations - http://jsfiddle.net/ignaciocorreia/R3EaJ/ Complex implementation and multi-browser - http://ricostacruz.com/jquery.transit/ $('div').css({"-webkit-transform":"translate(100px,100px)"});​ http://jsfiddle.net/xWCVf/5/ There are jQuery-plugins that help you achieve this like: http://ricostacruz.com/jquery.transit/ There's an

jquery prepend + fadeIn

大憨熊 提交于 2019-11-28 16:38:35
问题 I have this code: $.ajax({ url : url, data : {ids : JSON.stringify(jsonids), hotel_id: hotel_id}, success : function(response) { $('#be-images ul').prepend(response).fadeIn('slow'); }, dataType: 'html' }); but the fade In does not work...I want the content to be prepended and faded in...how will I do this? Thanks in advance! 回答1: Assuming response is HTML then try this: $(response).hide().prependTo("#be-images ul").fadeIn("slow"); When you do it this way: $('#be-images ul').prepend(response)

jQuery on window scroll animate background image position

 ̄綄美尐妖づ 提交于 2019-11-28 16:14:58
I am trying to achieve a scrolling effect using jQuery. I have a background div set to 100% browser window size with overflow hidden. This has a large background image that is approx. 1500px x 2000px. The effect I want is when the user scrolls down the page the background image moves at a percentage of the scrolled distance, so for every 200px scrolled down the page the image moves 10px in the same direction. Can anyone point me in the right direction? Is this even possible? : ) Many thanks in advance. UPDATE I have since tried variations on the suggestion by @Capt Otis but I'm still

Special color transition effect with pure jQuery animation // no ui or other libary

回眸只為那壹抹淺笑 提交于 2019-11-28 12:56:35
I am trying to create jQuery color animation without any external plugins. So far i could manage to do this with jQuery-ui but i want to learn this way with pure jQuery animate() Is is possible to do this with less code and without any external jQuery plugins on 1.8 ? Here is jsFiddle sample with jQuery 1.7.2 and ui jQuery: var Text = $('h1'); var Box = $('.box'); Text.click(function() { Text.animate({'color':'#f00'},600) .delay(200).animate({'color':'#ff0'},600) .delay(200).animate({'color':'#000'},600); }); Box.click(function() { Box.animate({'background-color':'#f00'},600) .delay(200)

jQuery window.scroll move div vertical in opposite direction

社会主义新天地 提交于 2019-11-28 12:35:47
问题 I have a div that scrolls down on the page scroll and when I scroll up the div scrolls up. I would like the opposite This is the code: // SCROLL BUTTON // -- iPhone picture should scroll in when down and down when up jQuery(window).scroll(function(){ jQuery(".iphonepic").stop().animate({ "top": (jQuery(window).scrollTop() - 0.00) + "px"}, "slow"); }); So when you scroll down, the div should go up vertically not the same as the scroll direction. Fiddle demo: http://jsfiddle.net/khaleelm/sQZ9G

Change Background Color CSS with Timer JQuery

人盡茶涼 提交于 2019-11-28 11:41:09
I was hoping someone could show me efficient JQuery to animate between 4 background colors in a div class. I would like these events to be triggered by time, not click or hover. I've seen posts on hover and toggle, but as someone not very proficient in JQuery, I didn't feel comfortable copying and pasting parts here and there. Thank you I dont know if you mean animated as in fading to the next, but heres a simple quick example of changing the color every 2 seconds. First example does not require jQuery. Live Demo function changeColor(curNumber){ curNumber++; if(curNumber > 4){ curNumber = 1; }

jquery animate a rotating div

只愿长相守 提交于 2019-11-28 11:29:39
I would like to rotate a div in an animate function such as $('div').animate({rotate: '30deg'},1000); I have found this: http://www.zachstronaut.com/posts/2009/08/07/jquery-animate-css-rotate-scale.html But I want to know if there is a more official way to do it or at least a different way. Thanks If you're open to using CSS3 in combination with jQuery, perhaps this method may be of some use to you: HTML <div id="click-me">Rotate</div> <div id="rotate-box"></div> CSS #rotate-box{ width:50px; height:50px; background:#222222; } @-moz-keyframes rotatebox /*--for firefox--*/{ from{ -moz-transform

jQuery: animate text color for input field?

元气小坏坏 提交于 2019-11-28 11:11:57
I've got this really simple piece of code that I thought was the correct way to get jQuery to animate the text color for a given input field. $('input').animate({color: '#f00'}, 500); But it won't work. However, I can change the text color: $('input').css('color', '#f00'); I've tried this in both Safari 4 and Firefox 3.5 with the same (lacking) results. I'd really appreciate any input on this problem as I'm running out of hair... Thanks. jQuery doesn't support color animations so you'll need the color plugin or, jQuery UI . Both allow you to use the syntax you're using for properties like