mirror of
https://github.com/Insality/druid
synced 2025-11-26 19:00:52 +01:00
Scroll style update, code style update
This commit is contained in:
@@ -578,34 +578,34 @@ function M:_check_soft_zone()
|
|||||||
local target = self.target_position
|
local target = self.target_position
|
||||||
local border = self.available_pos
|
local border = self.available_pos
|
||||||
local speed = self.style.BACK_SPEED
|
local speed = self.style.BACK_SPEED
|
||||||
local affected = false
|
local is_changed = false
|
||||||
|
|
||||||
-- Right border (minimum x)
|
-- Right border (minimum x)
|
||||||
if target.x < border.x then
|
if target.x < border.x then
|
||||||
local step = math.max(math.abs(target.x - border.x) * speed, 1)
|
local step = math.max(math.abs(target.x - border.x) * speed, 1)
|
||||||
target.x = helper.step(target.x, border.x, step)
|
target.x = helper.step(target.x, border.x, step)
|
||||||
affected = true
|
is_changed = true
|
||||||
end
|
end
|
||||||
-- Left border (maximum x)
|
-- Left border (maximum x)
|
||||||
if target.x > border.z then
|
if target.x > border.z then
|
||||||
local step = math.max(math.abs(target.x - border.z) * speed, 1)
|
local step = math.max(math.abs(target.x - border.z) * speed, 1)
|
||||||
target.x = helper.step(target.x, border.z, step)
|
target.x = helper.step(target.x, border.z, step)
|
||||||
affected = true
|
is_changed = true
|
||||||
end
|
end
|
||||||
-- Top border (maximum y)
|
-- Top border (maximum y)
|
||||||
if target.y < border.y then
|
if target.y < border.y then
|
||||||
local step = math.max(math.abs(target.y - border.y) * speed, 1)
|
local step = math.max(math.abs(target.y - border.y) * speed, 1)
|
||||||
target.y = helper.step(target.y, border.y, step)
|
target.y = helper.step(target.y, border.y, step)
|
||||||
affected = true
|
is_changed = true
|
||||||
end
|
end
|
||||||
-- Bot border (minimum y)
|
-- Bot border (minimum y)
|
||||||
if target.y > border.w then
|
if target.y > border.w then
|
||||||
local step = math.max(math.abs(target.y - border.w) * speed, 1)
|
local step = math.max(math.abs(target.y - border.w) * speed, 1)
|
||||||
target.y = helper.step(target.y, border.w, step)
|
target.y = helper.step(target.y, border.w, step)
|
||||||
affected = true
|
is_changed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
return affected
|
return is_changed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -735,9 +735,10 @@ function M:_update_free_scroll(dt)
|
|||||||
-- Inertion friction
|
-- Inertion friction
|
||||||
self.inertion = self.inertion * self.style.FRICT
|
self.inertion = self.inertion * self.style.FRICT
|
||||||
|
|
||||||
local affected = self:_check_soft_zone()
|
local is_changed = self:_check_soft_zone()
|
||||||
if affected then
|
if is_changed then
|
||||||
self.inertion = vmath.vector3(0, 0, 0)
|
self.inertion.x = 0
|
||||||
|
self.inertion.y = 0
|
||||||
end
|
end
|
||||||
if self.position.x ~= target.x or self.position.y ~= target.y then
|
if self.position.x ~= target.x or self.position.y ~= target.y then
|
||||||
self:_set_scroll_position(target.x, target.y)
|
self:_set_scroll_position(target.x, target.y)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ M["static_grid"] = {
|
|||||||
|
|
||||||
M["scroll"] = {
|
M["scroll"] = {
|
||||||
ANIM_SPEED = 0.2, -- gui.animation speed to point
|
ANIM_SPEED = 0.2, -- gui.animation speed to point
|
||||||
BACK_SPEED = 0.35, -- Lerp speed of return to soft position
|
BACK_SPEED = 0.1, -- Lerp speed of return to soft position
|
||||||
FRICT = 0.93, -- mult for free inert
|
FRICT = 0.93, -- mult for free inert
|
||||||
FRICT_HOLD = 0.79, -- mult. for inert, while touching
|
FRICT_HOLD = 0.79, -- mult. for inert, while touching
|
||||||
INERT_THRESHOLD = 2.5, -- speed to stop inertion
|
INERT_THRESHOLD = 2.5, -- speed to stop inertion
|
||||||
|
|||||||
Reference in New Issue
Block a user