Jquery / Jquery Tools Getting Smaller Effect

偶尔善良 提交于 2019-12-11 07:44:23

问题


I want to develop a screen with JQuery Tools(or just with JQuery) and HTML5. There will be a main panel at screen and it will have rounded square buttons on it. When user clicks a button this panel will get smaller and will be place at left side, something will appear at right side.

I mean:

Squares inside of big squares symbolizes buttons. When a user click a button at 1, panel will get smaller and go to left as like 2.

I may use that: JQuery Tools


回答1:


Looks like I found some time after all. Seems to work for me in Chrome 15, so will probably work in other webkit-based browsers as well. It's only a starting point so the cross-browser code needs some attention.

Edit: Updated demo which uses the shrinkTo jQuery plugin

HTML

<a href="#" id="shrinkify">Shrinkify me</a>
<div id="small"></div>
<div id="big">
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
</div>

CSS

#big {
    width:240px;
    height:240px;
    border:4px solid black;
    padding:5px;
    text-align:center;
    display:table-cell; 
    vertical-align:middle;
    position:relative;
    left:200px;
}

#big a {
    display:inline-block;
    border:2px solid black;
    -webkit-border-radius:5px;
    width:55px;
    height:55px;
}

#small {
    position:absolute;
    top:100px;
    width:120px;
    height:120px;
    visibility:hidden;
}

JavaScript

$('#shrinkify').click(function() {
    $('div#big').shrinkTo($('#small'), {
        duration: 1000,
        easing: 'swing',
        opacity: false
    });
    return false;
});



回答2:


See demo

The following will work for Chrome, Safari, FF 4+ and Opera 10+. The magic is in CSS3 transform and transition.

HTML:

<a href="#" id="r">Reset</a>
<div id="z"><!-- this is the button container --></div>

jQuery:

$('#z a').click(function(e){
    e.preventDefault();
    $('#z').addClass('dock');
});
$('#r').click(function(e){
    e.preventDefault();
    $('#z').removeClass('dock');
});

CSS:

#z {
    position: absolute; left: 150px; top: 150px;
    transform: scale(1.1);
    -o-transform: scale(1.1);
    -moz-transform: scale(1.1);
    -webkit-tranform: scale(1.1);
    transition: 0.6s ease-in;
    -o-transition: 0.6s ease-in;
    -moz-transition: 0.6s ease-in;
    -webkit-transition: 0.6s ease-in;
    -webkit-backface-visibility: hidden; // prevent webkit bug
}

#z.dock {
    left: -70px; top: -10px;
    transform: scale(0.5);
    -o-transform: scale(0.5);
    -moz-transform: scale(0.5);
    -webkit-transform: scale(0.5);
    transition: 1s ease-out;
    -o-transition: 1s ease-out;
    -moz-transition: 1s ease-out;
    -webkit-transition: 1s ease-out;
    -webkit-backface-visibility: hidden; // prevent webkit bug
}

See demo



来源:https://stackoverflow.com/questions/7075230/jquery-jquery-tools-getting-smaller-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!