diff --git a/README.md b/README.md index 90dc26e..8fc8c8b 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,8 @@ druid.set_default_style(your_style) - **[Hover](https://github.com/Insality/druid/blob/master/docs_md/01-components.md#hover)** - System Druid component, handle hover node state +- **[Swipe](https://github.com/Insality/druid/blob/master/docs_md/01-components.md#swipe)** - System Druid component, handle swipe gestures on node + Full info see on _[components.md](https://github.com/Insality/druid/blob/master/docs_md/01-components.md)_ diff --git a/docs_md/01-components.md b/docs_md/01-components.md index 25aafcb..e4c79b5 100644 --- a/docs_md/01-components.md +++ b/docs_md/01-components.md @@ -243,9 +243,30 @@ Create grid component with druid: `grid = druid:new_grid(parent_node, prefab_nod [Hover API here](https://insality.github.io/druid/modules/druid.hover.html) ### Overview -System Druid component, handle hover node state +System Druid component, handle hover node state. ### Setup -Create grid component with druid: `hover = druid:new_hover(node, callback)` +Create hover component with druid: `hover = druid:new_hover(node, callback)` -### Notes \ No newline at end of file +### Notes + + +## Swipe +[Swipe API here](https://insality.github.io/druid/modules/druid.swipe.html) + +### Overview +System Druid component, handle swipe actions on node + +### Setup +Create hover component with druid: `hover = druid:new_swipe(node, swipe_callback)` + +### Notes +- Swipe callback have next params: (self, swipe_side, distance, time) + - **self** - Druid self context + - **swipe_side**: *string* - values from ["up", "down", "left", "right"] + - **distance**: *number* - in pixels, distance of swipe + - **time**: *number* - in seconds, time of swiping +- Swipe trigger only, if all input actions was on swipe node. If action will be outside of node, swipe status will be reseted +- In swipe style table you can adjust minimal distance and maximum time to trigger swipe +- In swipe style table you can toggle type of swipe triggering. if SWIPE_TRIGGER_ON_MOVE setup to true - swipe will trigger as swipe can be triggered. If setup to false - swipe will trigger only on released action +- If you have stencil on swipe node and you don't want trigger it outside of stencil node, you can use `swipe:set_click_zone` to restrict swipe zone \ No newline at end of file diff --git a/druid/styles/empty/style.lua b/druid/styles/empty/style.lua index 27a9a43..3ede1b5 100644 --- a/druid/styles/empty/style.lua +++ b/druid/styles/empty/style.lua @@ -42,4 +42,11 @@ M["checkbox"] = { } +M["swipe"] = { + SWIPE_THRESHOLD = 50, + SWIPE_TIME = 0.4, + SWIPE_TRIGGER_ON_MOVE = false +} + + return M diff --git a/druid/styles/sprites/style.lua b/druid/styles/sprites/style.lua index b99409d..7d0d8be 100644 --- a/druid/styles/sprites/style.lua +++ b/druid/styles/sprites/style.lua @@ -49,4 +49,11 @@ M["checkbox"] = { } +M["swipe"] = { + SWIPE_THRESHOLD = 50, + SWIPE_TIME = 0.4, + SWIPE_TRIGGER_ON_MOVE = false +} + + return M