大佬教程收集整理的这篇文章主要介绍了jquery – 如何:Illustrator图形到网页动画,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要为图形的部分设置动画,例如飞鸟,人和车移动以及灯光开/关.
问题是,我该怎么做?我一直在研究SVG,CSS和JQuery动画.到目前为止,能够非常有效地使用CSS和JQuery.
如果有人在重新调整浏览器窗口大小(响应式布局)时能够以某种方式使动画工作,那将是很棒的,这就是我开始关注SVG的原因.我还需要动画在不同浏览器之间广泛兼容.
任何例子?你会推荐什么?
谢谢.
编辑:
我将使用JQuery和关键帧动画.我正在使用的Jquery动画功能是:
function animatethis(targetElement,speed,options,options2) { $(targetElement).animate(options,{ duration: speed,complete: function () { targetElement.animate(options2,{ duration: speed,complete: function () { animatethis(targetElement,options2); } }); } }); };
animatethis($(‘.big-cloud1’),40000,{‘left’:’= 120%’},{‘left’:’ – = 120%’}})
我还在计算重新调整浏览器大小时单个图像的大小.我的基础是全宽动画的最大比例.
这是以下代码:
// get main image var mainImage = $('.main-bg'); // Create new offscreen image to test var theImage = new Image(); theImage.src = mainImage.attr("src"); // Get accurate measurements from that. var maxWidth = theImage.width; jQuery.fn.resizeRatio = function(newHeight){ // work out new ratio var currentWidth = $('.main-bg').width(); var diff = maxWidth - currentWidth; var precent = diff / maxWidth; // get current image width var currentImage = new Image(); currentImage.src = $(this).attr("src"); var currentWidth = currentImage.width; // apply new width $(this).width(currentWidth - (currentWidth*precent)) } var initAnimation = function(){ $('#animation').imagesLoaded(function(){ $('#animation img').not('.sun,.main-bg').each(function( index ) { $(this).resizeRatio() }); }); } initAnimation() $(window).resize(function(){ initAnimation() });
但是,我可能会使用CSS和jQuery做这样的事情.使用百分比调整CSS中的图像大小,您可能能够在所有不同类型的屏幕上使用它.然而,许多工作都使得所有工作都能很好地协同工作.
所有jQuery也需要以百分比完成,或者你需要在调整大小时完成任务.
jQuery(window).resize(function(){ // Do your magic });
由于你大部分时间都不得不使用图像的宽度而不是高度,我可能会使用以下CSS:
img { width: (certain amount in percentages) height: auto; }
这将确保图像保持正确的比例. (但我猜你已经知道了,考虑到你正在计划开发这样一个项目).
如果您需要我更多地阐述我的想法,我会很乐意这样做.除此之外,我认为没有更好/更快的方法(除非你认为Flash是一个好方法).
以上是大佬教程为你收集整理的jquery – 如何:Illustrator图形到网页动画全部内容,希望文章能够帮你解决jquery – 如何:Illustrator图形到网页动画所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。