Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery标记云鼠标悬停停止它';他在动_Javascript_Jquery - Fatal编程技术网

Javascript jQuery标记云鼠标悬停停止它';他在动

Javascript jQuery标记云鼠标悬停停止它';他在动,javascript,jquery,Javascript,Jquery,下面是jQuery标记云效果的代码。当我加载页面时,它的菜单正在移动,但当我将鼠标悬停在菜单上时,它也在移动 当我将鼠标悬停在其上时,如何停止其移动 jQuery代码: $.fn.jcloud=function(settings) { jCloud={ tags: new Array(), container_id: 'jcloud', radius: 100, size: 20, areal: 180, iterX: 0, iterY:

下面是jQuery标记云效果的代码。当我加载页面时,它的菜单正在移动,但当我将鼠标悬停在菜单上时,它也在移动

当我将鼠标悬停在其上时,如何停止其移动

jQuery代码:

$.fn.jcloud=function(settings)
{
jCloud={
    tags: new Array(),
    container_id: 'jcloud',
    radius: 100,
    size: 20,
    areal: 180,
    iterX: 0,
    iterY: 0,
    iterx: 1,
    itery: 1,
    step: 4,
    flats: 1,
    speed: 100,
    start_speed: 1,
    timer: 0,
    clock: 10,
    stop: true,
    splitX: 0,
    splitY: 0,
    colors: new Array(),
    init: function (elem,settings) {
        $(elem).css('display','none');

        var i=0;
        $(elem).find('li').each(function(){
            jCloud.tags[i]=$(this).html();
            i++;
        });

        if (typeof(settings) != 'undefined')
        {
            try {
                if (typeof(settings.container_id) != 'undefined')
                {
                    this.container_id=settings.container_id;
                }
                if (typeof(settings.radius) != 'undefined')
                {
                    this.radius=settings.radius;
                }
                if (typeof(settings.size) != 'undefined')
                {
                    this.size=settings.size;
                }
                if (typeof(settings.areal) != 'undefined')
                {
                    this.areal=settings.areal;
                }
                if (typeof(settings.step) != 'undefined')
                {
                    this.step=settings.step;
                }
                if (typeof(settings.flats) != 'undefined')
                {
                    this.flats=settings.flats;
                }
                if (typeof(settings.speed) != 'undefined')
                {
                    if (settings.speed < 1)
                    {
                        settings.speed=1;
                    }

                    this.speed=settings.speed;
                }
                if (typeof(settings.clock) != 'undefined')
                {
                    this.clock=settings.clock;
                }
                if (typeof(settings.splitX) != 'undefined')
                {
                    if (Math.abs(settings.splitX) < 2*this.radius)
                    {
                        this.splitX=settings.splitX;
                    }
                }
                if (typeof(settings.splitY) != 'undefined')
                {
                    if (Math.abs(settings.splitY) < 2*this.radius)
                    {
                        this.splitY=settings.splitY;
                    }
                }
                if (typeof(settings.colors) != 'undefined' && settings.colors 
instanceof Array)
                {
                    this.colors=settings.colors;
                }
            } catch (e) {}
        }

        $(elem).replaceWith('<div id="'+this.container_id+'"></div>');

        $('#'+this.container_id).css({
                    'position':'relative',
                    'width':this.radius*2,
                    'height':this.radius*2,
                    'overflow':'hidden',
                    'padding': '0px'
                    });

        $('#'+this.container_id).mousemove(function(e){
            var centerX=$(this).offset().left+jCloud.radius;
            var centerY=$(this).offset().top+jCloud.radius;

            jCloud.speed=jCloud.start_speed;
            jCloud.iterx=(centerX-e.pageX)/jCloud.radius;
            jCloud.itery=(centerY-e.pageY)/jCloud.radius;
        });

        $('#'+this.container_id).mouseover(function()
        {
            jCloud.stop=true, 0, 'rotate';
        });

        $('#'+this.container_id).mouseout(function()
        {
            jCloud.stop=false;
        });

        $('body').append('<div id="jcloud-buffer"></div>');
        $('#jcloud-buffer').css({
                    'display': 'none',
                    'padding': '0px',
                    'white-space': 'nowrap'
                });
    },
    render: function() {
        $('#'+this.container_id).empty();

        this.start_speed=this.speed;

        for (var j in this.tags)
        {
            this.draw(j);
        }

        this.cloud();
    },
    draw: function(id) {
        $('#jcloud-buffer').html('<div class="jtag" id="jtag-
'+id+'">'+this.tags[id]+'</div>');

        var taghtml=$('#jcloud-buffer').html();
        var width=$('#jcloud-buffer').width();
        var height=$('#jcloud-buffer').height();

        $('#'+this.container_id).append(taghtml);

        $('#jtag-'+id).attr('width',width);
        $('#jtag-'+id).attr('height',height);
    },
    cloud: function(iter,flat_iter,update) {
        var count=this.tags.length;
        var per_flat=Math.ceil(count/this.flats);
        var delta=Math.round(360/per_flat);
        var deg=0;
        var flat_deg=0;

        if (typeof(iter) != 'undefined')
        {
            deg=Math.floor(iter);
        }

        if (typeof(flat_iter) != 'undefined')
        {
            flat_deg=Math.floor(flat_iter);
        }

        var flat_offset=Math.floor(this.areal/(this.flats+1))/2+flat_deg;
        var flat_delta=Math.floor(this.areal/this.flats);

        var flat_co=0;
        for (var j in this.tags)
        {
            this.pos(deg,j,parseInt($('#jtag-'+j).attr('width')),parseInt($('#jtag-   
'+j).attr('height')),flat_offset,update);
            deg+=delta;

            flat_co++;

            if (flat_co>=per_flat)
            {
                flat_offset+=flat_delta;
                flat_co=0;
                deg+=flat_delta;
            }
        }
    },
    pos: function(degree,id,width,height,offset,update) {
        var radian=degree*Math.PI/180;
        var ell_offset=offset*Math.PI/180;
        var size_offset=0;

        var size=this.size+size_offset;

        var X=this.radius+Math.sin(radian)*this.radius*Math.cos(ell_offset)-width/2;
        var Y=this.radius-Math.cos(radian)*this.radius-height/2;

        size=(1+Math.cos(radian-1.57)*Math.sin(ell_offset))*size/2;

        if (size < 1)
        {
            size=1;
        }

        if (typeof(update) == 'undefined' || update==false)
        { 
            if (this.colors.length > 0)
            {
                for (var i in this.colors)
                {
                    if ((parseInt(id)+1) % (this.colors.length-i) == 0)
                    {
                        //$('#jtag-'+id).css('color',this.colors[this.colors.length-
i-1]);
                        //$('#jtag-
'+id).children('a').css('color',this.colors[this.colors.length-i-1]);

                        $('#jtag-
'+id).attr('style','color:'+this.colors[this.colors.length-i-1]+' !important');
                        $('#jtag-
'+id).children('a').attr('style','color:'+this.colors[this.colors.length-i-1]+' 
!important');
                        break;
                    }
                }
            }

            $('#jtag-'+id).css({
                'position':'absolute',
                'white-space': 'nowrap',
                'font-weight': 'normal'
            });
        }

        var opacity=1;
        opacity=(1+Math.cos(radian-1.57)*Math.sin(ell_offset))*opacity/2;

        if (opacity<.5)
        {
            opacity=.5;
        }

        if (this.splitX)
        {
            var offsetX=parseInt(this.splitX);
            if (id%2==0)
            {
                X-=offsetX;
            } else
            {
                X+=offsetX;
            }
        } 

        if (this.splitY)
        {
            var offsetY=parseInt(this.splitY);
            if (id%2==0)
            {
                Y-=offsetY;
            } else
            {
                Y+=offsetY;
            }
        } 

        $('#jtag-'+id).css({
                'left':Math.round(X),
                'top':Math.round(Y),
                'font-size':Math.floor(size)+'px',
                'opacity': opacity
            });



    },
    update: function() {
        this.timer++;

        var interval=Math.floor(.1/jCloud.speed);

        if (this.timer < interval)
        {
            return;
        }

        if (this.stop)
        {
            this.speed=this.speed-(this.speed*.1);
        }

        this.timer=1;

        if (this.iterX >= 360)
        {
            this.iterX=360-this.iterX;
        }

        if (this.iterY >= 360)
        {
            this.iterY=360-this.iterY;
        }

        this.iterX+=this.iterx;
        this.iterY+=this.itery;

        this.cloud(this.iterY,this.iterX,true);
    }
}

jCloud.init($(this),settings);

jCloud.render();

jCloudInterval=window.setInterval("jCloud.update()",jCloud.clock);

}
$.fn.jcloud=函数(设置)
{
jCloud={
标记:新数组(),
容器id:“jcloud”,
半径:100,
尺码:20,
地区:180,
iterX:0,
实验结果:0,
iterx:1,
研究结果:1,
步骤:4,
单位:1,,
速度:100,,
启动速度:1,
计时器:0,
钟:10,,
停:是的,
splitX:0,
斯普利蒂:0,
颜色:新数组(),
初始化:功能(元素、设置){
$(elem.css('display','none');
var i=0;
$(elem).find('li').each(function(){
jCloud.tags[i]=$(this.html();
i++;
});
如果(设置的类型)!=“未定义”)
{
试一试{
if(typeof(settings.container_id)!=“未定义”)
{
this.container\u id=settings.container\u id;
}
if(typeof(settings.radius)!=“未定义”)
{
this.radius=settings.radius;
}
if(typeof(settings.size)!=“未定义”)
{
this.size=settings.size;
}
if(typeof(settings.areal)!=“未定义”)
{
this.areal=settings.areal;
}
if(typeof(settings.step)!=“未定义”)
{
this.step=settings.step;
}
if(typeof(settings.flats)!=“未定义”)
{
this.flats=settings.flats;
}
if(typeof(settings.speed)!=“未定义”)
{
如果(设置速度<1)
{
设置。速度=1;
}
此.speed=settings.speed;
}
if(typeof(settings.clock)!=“未定义”)
{
this.clock=settings.clock;
}
if(typeof(settings.splitX)!=“未定义”)
{
if(Math.abs(settings.splitX)<2*此半径)
{
this.splitX=settings.splitX;
}
}
if(typeof(settings.splitY)!=“未定义”)
{
if(Math.abs(settings.splitY)<2*this.radius)
{
this.splitY=settings.splitY;
}
}
if(typeof(settings.colors)!=“未定义”和&settings.colors
instanceof数组)
{
this.colors=settings.colors;
}
}捕获(e){}
}
$(元素)。替换为(“”);
$(“#”+this.container_id).css({
'位置':'相对',
“宽度”:这是半径*2,
“高度”:此为半径*2,
“溢出”:“隐藏”,
“填充”:“0px”
});
$(“#”+this.container_id).mousemove(函数(e){
var centerX=$(this).offset().left+jCloud.radius;
var centerY=$(this).offset().top+jCloud.radius;
jCloud.speed=jCloud.start\u speed;
jCloud.iterx=(centerX-e.pageX)/jCloud.radius;
jCloud.itery=(centerY-e.pageY)/jCloud.radius;
});
$('#'+this.container_id).mouseover(函数()
{
jCloud.stop=true,0,‘旋转’;
});
$('#'+this.container_id).mouseout(函数()
{
jCloud.stop=false;
});
$('body')。追加('');
$('#jcloud buffer').css({
“显示”:“无”,
“填充”:“0px”,
“空白”:“nowrap”
});
},
render:function(){
$(“#”+this.container_id).empty();
this.start\u速度=this.speed;
for(此.tags中的var j)
{
这是图(j);
}
这个。云();
},
绘图:函数(id){
$('#jcloud buffer').html(''+this.tags[id]+'');
var taghtml=$('#jcloud buffer').html();
var width=$('#jcloud buffer').width();
var height=$('#jcloud buffer').height();
$('#'+this.container_id).append(taghtml);
$('#jtag-'+id).attr('width',width);
$('jtag-'+id).attr('height',height);
},
云:功能(iter、平板iter、更新){
var count=this.tags.length;
var per_flat=Math.ceil(count/this.flats);
var delta=数学圆(360/每单位平面);
var-deg=0;
var平坦度=0;
if(类型化(iter)!=‘未定义’)
{
deg=数学地板(iter);
}
if(类型(平面)!=‘未定义’)
{
平面度=数学地板(平面);
}
var flat_offset=数学地板(此面积/(此平面+1))/2+平面度;
var flat_delta=数学地板(此面积/此平面);
var flat_co=0;
for(此.tags中的var j)
{
这个.pos(deg,j,parseInt($('#jtag-'+j).attr('width')),parseInt($('#jtag-
'+j).属性('高度')、平面偏移、更新);
deg+=δ;
平坦的co++;
如果(单位面积>=每单位面积)
{
平面偏移量+=平面增量;
平面系数=0;
deg+=平坦的三角洲;
}
}
},
位置:功能(度、id、宽度、高度、偏移、更新){
var弧度=度*Math.PI/180;
var ellu offset=offset*Math.PI/180;
var size_offset=0;
变量大小=此。大小+大小\u偏移量;
var X=此.radius+数学正弦(弧度)*此.radius*数学cos(厄尔偏移)-宽度/2;
var Y=此.radius数学cos(弧度)*此.radius-height/2;
大小=(1+Math.co)
$('#'+this.container_id).mouseover(function()
{
    jCloud.stop=false;
});
$('#'+this.container_id).mouseover(function()
{
    jCloud.stop=true;
});