From 0472e5d6db08696d4472d399407ff251274d69dc Mon Sep 17 00:00:00 2001 From: Insality Date: Fri, 2 Apr 2021 10:07:22 +0300 Subject: [PATCH] Little code refactor, update changelog --- docs_md/changelog.md | 4 ++-- druid/base/hover.lua | 4 ++-- druid/helper.lua | 5 ++--- druid/styles/default/style.lua | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs_md/changelog.md b/docs_md/changelog.md index 177c2d1..9e16f83 100644 --- a/docs_md/changelog.md +++ b/docs_md/changelog.md @@ -136,17 +136,17 @@ Also check _component.template.lua_ what you can use for your own custom compone Desc -- Input component: rename field _selected_ to _is_selected_ (according to the docs) - Add EmmyLua annotations. See how to use it FAQ - Lang text now can be initialized without default locale id +- **Fix**: Input component: rename field _selected_ to _is_selected_ (according to the docs) - **#92** Setup repo for CI and unit tests. (Yea, successful build and tests badges!) +- **#102** __[BREAKING]__ Removed `component:increase_input_priority` component function. Use `component:set_input_priority` function instead. The bigger priority value processed first. The value 10 is default for Druid components, the 100 value is maximum priority for acquire input in _drag_ and _input_ components - **#103** Add `helper.centate_nodes` function. It can horizontal align several Box and Text nodes - **#105** Add `Input:select` and `Input:unselect` function. - **#106** Add `Input IS_UNSELECT_ON_RESELECT` style param. If true, it will be unselect input on click on input box, not only on outside click. - **#108** Add component interests const to `component.lua` - **#116** You can pass Text component in Input component instead of text node - **#124** Add `Scroll:set_click_zone` function. This is just link to `Drag:set_click_zone` function inside scroll component. -- **#102** __[BREAKING]__ Removed `component:increase_input_priority` component function. Use `component:set_input_priority` function instead. The bigger priority value processed first. The value 10 is default for Druid components, the 100 value is maximum priority for acquire input in _drag_ and _input_ components -- Add constants for priorities: _const.PRIORITY_INPUT_, _const.PRIORITY_INPUT_HIGH_, _const.PRIORITY_INPUT_MAX_. -- __[BREAKING]__ If you use in you custom components interest: `component.ON_INPUT_HIGH` you should replace it with `const.PRIORITY_INPUT_HIGH` as third param, and place it with usual `component.ON_INPUT`. For example: _before:_ diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 1fe9ddf..71a7d85 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -27,8 +27,8 @@ function Hover.init(self, node, on_hover_callback) self._is_hovered = false self._is_mouse_hovered = false - self._is_enabled = true + self._is_mobile = helper.is_mobile() self.on_hover = Event(on_hover_callback) self.on_mouse_hover = Event() @@ -41,7 +41,7 @@ function Hover.on_input(self, action_id, action) end -- Disable nil (it's mouse) hover or mobile platforms - if not action_id and helper.is_mobile() then + if self._is_mobile and not action_id then return false end diff --git a/druid/helper.lua b/druid/helper.lua index 6f9824f..f7f2fbe 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -5,8 +5,6 @@ local const = require("druid.const") local M = {} -local system_name = sys.get_sys_info().system_name - --- Text node or icon node can be nil local function get_text_width(text_node) if text_node then @@ -183,7 +181,8 @@ end --- Check if device is mobile (Android or iOS) -- @function helper..is_mobile function M.is_mobile() - return const.CURRENT_SYSTEM_NAME == const.OS.IOS or const.CURRENT_SYSTEM_NAME == const.OS.ANDROID + return const.CURRENT_SYSTEM_NAME == const.OS.IOS or + const.CURRENT_SYSTEM_NAME == const.OS.ANDROID end diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index 111d291..a71d210 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -65,9 +65,8 @@ M["scroll"] = { INERT_SPEED = 30, -- koef. of inert speed EXTRA_STRETCH_SIZE = 100, -- extra size in pixels outside of scroll (stretch effect) POINTS_DEADZONE = 20, -- Speed to check points of interests in no_inertion mode - - SCROLL_WHEEL_SPEED = 20, - + WHEEL_SCROLL_SPEED = 20, + WHEEL_SCROLL_INVERTED = false, SMALL_CONTENT_SCROLL = true, -- If true, content node with size less than view node size can be scrolled }