本文作者html5tricks,转载请注明出处
今天我们要来分享一组很酷的jQuery插件,这款jQuery插件实现了6组不同样式的超酷仪表盘指示器动画。仪表盘的背景是一张图片,通过jQuery来动态生成一些属性标签,比如仪表盘的刻度和指针等。效果非常不错。
HTML代码:
<span id="airspeed"></span> <span id="attitude"></span> <span id="altimeter"></span> <span id="turn_coordinator"></span> <span id="heading"></span> <span id="variometer"></span>
JavaScript代码:
// Dynamic examples var attitude = $.flightIndicator('#attitude', 'attitude', {roll:50, pitch:-20, size:200, showBox : true}); var heading = $.flightIndicator('#heading', 'heading', {heading:150, showBox:true}); var variometer = $.flightIndicator('#variometer', 'variometer', {vario:-5, showBox:true}); var airspeed = $.flightIndicator('#airspeed', 'airspeed', {showBox: false}); var altimeter = $.flightIndicator('#altimeter', 'altimeter'); var turn_coordinator = $.flightIndicator('#turn_coordinator', 'turn_coordinator', {turn:0}); // Update at 20Hz var increment = 0; setInterval(function() { // Airspeed update airspeed.setAirSpeed(80+80*Math.sin(increment/10)); // Attitude update attitude.setRoll(30*Math.sin(increment/10)); attitude.setPitch(50*Math.sin(increment/20)); // Altimeter update altimeter.setAltitude(10*increment); altimeter.setPressure(1000+3*Math.sin(increment/50)); increment++; // TC update turn_coordinator.setTurn(30*Math.sin(increment/10)); // Heading update heading.setHeading(increment); // Vario update variometer.setVario(2*Math.sin(increment/10)); }, 50);
很好很好