0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

フェード効果付きスライドショーをタイマーで作る

Last updated at Posted at 2025-03-31

動画も公開しました

こめIndexのエラー対策ためIsBlank関数で空のテーブル判定をしていましたが、
正しくはIsEmptyで判定しなくてはいけませんでした。
動画も修正して再公開しました。

▼画面のOnVisibleプロパティ

ClearCollect(imagelist,データソース);//リストをコレクションに格納
Set(_count,1)//カウンタをリセット

配置するコントロールは最小構成で
画像2つ、図形(白四角で背景)1つ、タイマー2つです。

それぞれの設定を以下に記します。

Timer_1

▽ディスプレイ
▼期間(Duration)
3000//3秒・フェードの時間

▼自動開始オン
▼繰り返しオフ
▼自動一時停止オフ

▽詳細設定
▼OnTimerEnd

Set(_timer2start,false); //タイマー2のstart用変数をfalse
Set(_timer2start,true);  //タイマー2のstart用変数をtrue
If(
    _count < CountRows(col_image), 
    //カウントがコレクションのレコード数より小さい時、カウントを1増やす
    Set(
        _count,
        _count + 1
    ),
    //カウントがコレクションのレコード数以上の時、カウントを1にする
    Set(
        _count,
        1
    )
);

▼OnTimerStart

If(
    _count < CountRows(col_image),
    //▽カウントが画像の枚数未満だったら_image2に次のレコードを準備
    Set(
        _image2,
        //▽このIfはアプリ起動時のIndex関数のエラー回避
        If(
            !IsEmpty(col_image),
            //Index関数でコレクションから次のレコードを取得
            Index(
                col_image,
                _count + 1
            )
        )
    ),
    //▽カウントが画像の枚数以上になったら_image2に一番初めのレコードを格納
    Set(
        _image2,
        //▽このIfはアプリ起動時のIndex関数のエラー回避
        If(
            !IsEmpty(col_image),
            //Index関数で一番初めのレコードを取得
            Index(
                col_image,
                1
            )
        )
    )
)

▼Start

_timer1start

Timer_2

▽ディスプレイ
▼期間(Duration)
3000//3秒・画像表示時間
▼自動開始オフ
▼繰り返しオフ
▼自動定置時停止オフ

▽詳細設定
▼OnTimerEnd

Reset(Timer_1);         //タイマー1をリセット
Set(_timer1start,false); //一度変数をfalseにする
Set(_timer1start,true);  //変数をtrueにしてタイマー1をスタート

▼Start

_timer2start

Image_1

▽Image

If(!IsEmpty(imagelist),Index(imagelist,_count).jpg.Large

▽Transparency

Timer_1.Value/Timer1_1.Duration //タイマー1が進むと透明になる

Image_2

▽Imageプロパティ

_image2.jpg.Large //タイマー1のOnTimerStartプロパティで設定

▽Transparency

1-Timer1_1.Value/Timer1_1.Duration //タイマー1が進むと出てくる

以上で設定は終了です。

Image_1で表示している画像をTimer_1の経過時間で透明にしていき、
次の画像を表示しているImage_2を逆に透明から表示していきます。

スライドショー.gif
うまくいけばこのようにフェード効果付きのスライドショーが表示されます。
ぜひお試しください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?