jquery-animate

Error while using jquery animate “Out of memory at line: 13”

半世苍凉 提交于 2019-12-06 10:57:29
I am trying to display my products animation with the following code (jquery) var prodNum = <%=prodNum %>; var i = 1; $.timer(5000, function(timer) { $(".prods").hide("slide", { direction: "down" }, 500, function() { $(".prods").html("<div class=\"prod\">" + $("#pr" + ((4*i) % prodNum)).html() + "</div>" + "<div class=\"prod\">" + $("#pr" + ((4*i + 1) % prodNum)).html() + "</div>" + "<div class=\"prod\">" + $("#pr" + ((4*i + 2) % prodNum)).html() + "</div>" + "<div class=\"prod\">" + $("#pr" + ((4*i + 3) % prodNum)).html() + "</div>"); $(".prods").show("slide", { direction: "down" }, 500); i++

jQuery toggle click

青春壹個敷衍的年華 提交于 2019-12-06 10:11:56
问题 Say I need an element to animate when clicked. To do this I just: $('#header .icon').click(function() { $('#header form').animate({width:'195px'}); }); But how would I make it so that when I click the element again the opposite animate takes place? (e.g. animate to width: 0px; ) 回答1: You can use .toggle() like this: $('#header .icon').toggle(function() { $('#header form').animate({width:'195px'}); }, function() { $('#header form').animate({width:'0px'}); }); If it was initially out you could

jQuery - Randomize boxes and animate them on window load

僤鯓⒐⒋嵵緔 提交于 2019-12-06 08:29:42
问题 On the picture bellow is what I'm trying to build: Idea is that all the boxes are hidden until whole page loads. Then they should have set random positions around browser view port and then they (boxes) needs to be animated to move to their proper positions. Boxes have absolute positions in CSS, and my idea is when windows loads to put initial position in variable, then randomize position of the box, and then finally move it to the starting position. Hope I'm clear :) Here is my current setup

Animating externally loaded SVG with Keith Wood's jQuery SVG plugin

你。 提交于 2019-12-06 08:18:46
I'm trying to animate the fill color of a group of path's loaded from an external SVG using Keith Wood's plugin . First I import the SVG into a div container: $(document).ready(function() { $('#header-main').svg({loadURL: 'header.svg'}); var svg = $('#header-main').svg('get'); }); The SVG file looks like this: <svg> <g id="group1"> <path d="M0,22.943V0.223h1.413v22.721H0z"/> <path etc../> </g> </svg> I can change the fill color of the group or individual paths like so: svg.style('#group1 {fill: black}'); Now when I try to animate the paths like this: $('path').animate({svgFill: 'blue'}, 500);

jQuery - call function when animate

风流意气都作罢 提交于 2019-12-06 07:41:25
Is it possible to call some function in .animate event? I have to call resize() function for every resize event on some div. For an example, I call function on window resize event: $(window).resize(resize); But now I wish to call this function inside animate event(every changed pixel(like .resize does)). selector['el']['box'].animate({width:selector['el']['box'].width() - 250}, 500); selector['el']['box'].promise().done(function() {resize();}); But this is not what I want, because I wish resize function to be called all the time, not only on the end... you could use its step function, like:

rotate image with jquery compatible with IE7/8

穿精又带淫゛_ 提交于 2019-12-06 07:33:47
问题 I have tried so many ways/plugins, and the one that attracts me the most is jquery.rotate But, it doesn't work (at least for me) in Internet Explorer 7 and 8 (the images just disappear). My objective is to hover images and make them animate their rotation, it works in Safari + Firefox but not IE. Is there a way to achieve this and be compatible with most browsers and IE 7 and 8? EDIT : In the end it turns out that both jQuery Rotate and Raphaël do work in IE 7 and 8! I didn't have a chance to

Repeating a nested animation in jQuery

烈酒焚心 提交于 2019-12-06 06:13:46
I have an animation (a div with a background image) which has another animation as callback. A car drives from right to left, then turns and drives back. all with some delay. I want the whole animation run again infinite times. Here is the code: var tempoPolente = 10000; var viewport = $(window).width() + 300; // Animation var polenteAnim = function() { $("#polente").removeClass('flip').animate({"right": "+="+viewport}, tempoPolente, 'linear', function() { setTimeout(function() { $("#polente").addClass("flip").animate({"right": "-="+viewport}, tempoPolente, 'linear'); }, 1000); }); }; dc5

Element “flickers” and Moves on fadeOut/fadeIn

拜拜、爱过 提交于 2019-12-06 06:03:22
问题 I'm using the following code to fadeOut and fadeIn content divs on a page (jsfiddle here)... HTML: <ul> <li><a id="indexNav" href="index.html">Home</a></li> <li><a id="aboutNav" href="about.html">About</a></li> </ul> <div id="indexContent"> This is the main page content. </div> <div id="aboutContent"> This is the about page content. </div> CSS: ul { float: left; display: block; margin-top: 50px; margin-left: 0px; } ul li { list-style: none; display: block; margin-top: 5px; } ul li a { display

“puff of smoke” effect javascript sprite animation

给你一囗甜甜゛ 提交于 2019-12-06 05:58:40
This code and animation works perfectly on jQuery 1.4.4 and below, but not on later versions. Could anyone shed some light on this issue and help with a version that works with latest jQuery. I have provided a fiddle below. http://jsfiddle.net/Y7Ek4/10/ The poof effect basically relies on adjusting the background-position to create a css sprite animation, but it borked on new jQuery. jQuery's animate is no longer appropriate for sprite animations. I had to roll my own using setTimeout . The effect is inspired by the one used for removing items from OS X dock. The sprite: The relevant JS code:

Animating slider handle when altering the jQuery UI slider value option?

99封情书 提交于 2019-12-06 05:57:31
问题 I'm using the jQuery UI (1.8) slider widget to enable the user to slide/scroll a series of icons horizontally. Sometimes I want to move the slider programatically and the correct way to do that is by altering the option "value", like this: $("#content-slider").slider("option", "value", 37); The motion of the slider handle is instant though. I'd like the motion to be animated. This can be done on a lower level, by animating the "left" CSS property of the handle, like this: $(".ui-slider-handle