
一款可以制作鼠標跟隨星星特效的jQuery插件。你可以自定義跟隨鼠標移動的星星的數量,顏色,范圍等,也可以使用自定義的圖片來代替星星。HTML結構你可以指定一個容器,在這個容器中生成鼠標跟隨星星特效。<div class="container"></div>
初始化插件在頁面DOM元素加載完畢之后,可以通過jstars()方法來初始化該插件。$('#container').jstars({ image_path: 'images', // folder with stars assets style: 'white', // optional, star color, default = white frequency: 5 // optional, from 1 to 19});
下面是該鼠標跟隨插件可用的配置參數:image_path:默認值:''。圖片的路徑。image:默認值:'jstar-map.png'。圖片的名稱。style:默認值:'white',星星的顏色。frequency:默認值:12。星星的數量。style_map:默認值:這是一個對象,用于標識雪碧圖中每一行的坐標。width:默認值:單個星星的寬度。height:默認值:單個星星的高度。delay:默認值:星星旋轉的速度。
jQuery('#example-rand').jstars({ image_path: '', // this is requried option image: 'jstar-map.png', // this is requried option style: 'white', frequency: 12, // if you check the sprite image you will see it has // several rows of different colors // style map sets the coordinates of each row style_map: { white: 0, blue: -27, green: -54, red: -81, yellow: -108 }, width: 27, // single star width height: 27, // single star height delay: 300 // rotate speed});