jQuery UI の show を使い、徐々に拡大するアニメーションで表示する

jQuery UI の show プラグインを使い、徐々に拡大するアニメーション動作で、要素を出現させる方法。show() の1つ目の引数に、「scale」を指定する。3つ目の引数で、アニメーション動作速度を、ミリ秒単位で、調整できる。

実装例(サンプル)

「Show」ボタンをクリックすると、徐々に拡大するアニメーション動作で、このボックスを出現させる。

実装例(サンプル)の動作について

「Show」ボタンをクリックすると、徐々に拡大するアニメーション動作で、カーキ色のボックスを出現させる。

実装例のソースコード

読み込み

読み込み方は、2種類ある。パスは、それぞれ、アップロードした場所を指定する。

まとめて読み込む場合
<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="ui/jquery-ui-1.8.12.custom.min.js"></script>
個別に読み込む場合
<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="ui/jquery.ui.button.js"></script>
<script type="text/javascript" src="ui/jquery.effects.core.js"></script>
<script type="text/javascript" src="ui/jquery.effects.scale.js"></script>

JavaScript

<script>
<!--
jQuery( function() {
    jQuery( '#jquery-ui-show' ) . button();
    jQuery( '#jquery-ui-show' ) . click( function() {
        jQuery( '#jquery-ui-effect' ) . show( 'scale', { percent: 100 }, 1500 );
    } );
} );
// -->
</script>

CSS

<style>
<!--
#jquery-ui-effect {
    display: none;
    width: 400px;
    padding: 50px 15px;
    font-size: 15px;
    background: khaki;
}
-->
</style>

HTML

<button id="jquery-ui-show">show</button>
<div id="jquery-ui-effect" class="ui-widget-content ui-corner-all">
    <p>「Show」ボタンをクリックすると、徐々に拡大するアニメーション動作で、このボックスを出現させる。</p>
</div>

スポンサード リンク

カテゴリー: JavaScript, jQuery, jQuery UI, Show, アニメーション パーマリンク