# GestureState

[SwiftUI](..) ⟩ [Gestures]() ⟩ GestureState

{% hint style="danger" %}
<mark style="color:purple;">**`@GestureState`**</mark> will <mark style="color:red;">**reset**</mark> to the <mark style="color:red;">**original value**</mark> when the gesture <mark style="color:orange;">**ends**</mark>.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %}
Since <mark style="color:purple;">**`@GestureState`**</mark> property will <mark style="color:red;">**reset**</mark> itself, we need <mark style="color:orange;">**another**</mark> [`@State`](../view/state/value/state) property to save the <mark style="color:red;">**final state**</mark>.
{% endhint %}
{% endtab %}

{% tab title="💈範例" %}
* [long-press](long-press "mention")
* [drag](drag "mention")
* [longpressdrag](combine/sequenced/longpressdrag "mention") - use custom [enum](../../swift/type/category/basic/enum "mention") for its gesture state.
{% endtab %}

{% tab title="📗 參考" %}
* [ ] Paul ⟩ [What is the @GestureState property wrapper?](https://www.hackingwithswift.com/quick-start/swiftui/what-is-the-gesturestate-property-wrapper) - mentioned "<mark style="color:orange;">**transaction**</mark>".&#x20;
* [ ] NSScreencast ⟩ [SwiftUI Gestures](https://nsscreencast.com/episodes/400-swiftui-gestures)
{% endtab %}

{% tab title="📘 手冊" %}
* [SwiftUI](https://developer.apple.com/documentation/swiftui) ⟩ [Gestures](https://developer.apple.com/documentation/swiftui/gestures) ⟩ [GestureState](https://developer.apple.com/documentation/swiftui/gesturestate) (<mark style="color:red;">**struct**</mark>)
{% endtab %}

{% tab title="👥 相關" %}
* is [wrapper](../../swift/type/prop/wrapper "mention").
* used by [long-press](long-press "mention"), [drag](drag "mention").
{% endtab %}
{% endtabs %}
