Skip to content

Instantly share code, notes, and snippets.

@todokr
Created April 25, 2013 20:28
Show Gist options
  • Save todokr/5462873 to your computer and use it in GitHub Desktop.
Save todokr/5462873 to your computer and use it in GitHub Desktop.
VIのJS
(function($){
//フェードロールオ−バー
$(function(){
$("img.roll").imgOvAnime();
});
$.fn.imgOvAnime = function(option){
var o = $.extend({
ovStr: "_o",
speed: 300,
type: "fade"
},option);
var overElements = $(this);
//フェード関数
function fade(){
var ovElm = overElements;
var ovStr = o.ovStr;
var speed = o.speed;
ovElm.css({position:"relative"}).each(function(){
var self = $(this);
var url = self.attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1"+ovStr+"$2");
var ovImg = $("<img>").attr("src",url).css({position: "absolute"});
function anime(a_alp){
self.stop().animate({opacity:a_alp},speed);
}
self.before(ovImg).hover(
function(){
anime("0");
},
function(){
anime("1");
});
});
}
//アニメーションタイプ確認
switch(o.type){
case "fade":
fade();
break;
}
}
//メインカラムとサイドバーの高さを揃える
var mainH = $('article').height();
var asideH = $('aside').height();
if (mainH >= asideH ) {
$('aside').height(mainH);
} else{
$('article').height(asideH);
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment