このページのトップへ
State Toggle

State Toggle

Use a multi-state box to toggle between different states.

中級.png

初心者

9K

出版された:

February 12, 2020

酒を楽しむ少女

によって

アンカー 1
開発者を雇う

説明例

In this example we use a multi-state box element to display multiple views. In our case, we have two views, one showing the front and the other showing the back of a mobile phone.

Pressing a button changes the state of the multi-state box which toggles the view.

コード例

タブ1

.

タブ2

.

タブ3

.

このコードによる解決は複雑になる可能性がある。

どのように構築したか

ページ要素

In our site we added the following page elements:

  • Multi-State Box element: Holds the images and texts for the "front" and "back" states.

  • Image and text elements: The contents of the two states.

  • Four buttons: Two buttons with the ID "Front Face" and two with the ID "Back Face". Each set of two buttons with the same label has a black version and a white version. The buttons with the same labels are layered on top of each other.


コード

The onReady() function adds an event handler to each of the four buttons. There are two possible event handlers defined as the toggleFront() and toggleBack() functions. The toggleFront() function switches from the "front" state to the "back" state and toggleBack() switches the states in the other direction. 

 

On each state change:

  • The show() and hide() functions are used to create a gliding effect on the white buttons, making the buttons look like a toggle switch.

  • The multi-state box changes states, toggling the view that is shown to site visitors. Note that the animations on the elements in the state box are set in the Editor and occur each time the state changes.

使用したAPI

コード以外の例。

コード以外の例。

コード以外の例。

コード以外の例。

関連記事

開発者を雇う

Veloソリューションは強力なツールですが、自力で構築するのは困難です。経験豊富なVelo開発会社に構築をお任せください。

関連例

これは役に立ったか?

はい

|

いいえ

ご意見ありがとう!

サイト・コンテンツの変更

サイト・コンテンツの変更

ユーザーのインタラクションに応じてサイトのコンテンツを変更する。

中級.png

初心者

ダークモード

ダークモード

サイトをダークモードで表示する。

中級.png

中級

崩壊要素

崩壊要素

要素グループの折りたたみと展開。

中級.png

初心者

アンカー2
ページ下