jf-roku/components/section/section.bs

98 lines
3.4 KiB
Plaintext
Raw Normal View History

import "pkg:/source/utils/misc.bs"
2022-09-03 20:06:57 +00:00
sub init()
m.showFromBottomAnimation = m.top.findNode("showFromBottomAnimation")
m.showFromBottomPosition = m.top.findNode("showFromBottomPosition")
m.showFromBottomOpacity = m.top.findNode("showFromBottomOpacity")
m.showFromTopAnimation = m.top.findNode("showFromTopAnimation")
m.showFromTopPosition = m.top.findNode("showFromTopPosition")
m.showFromTopOpacity = m.top.findNode("showFromTopOpacity")
m.scrollOffTopAnimation = m.top.findNode("scrollOffTopAnimation")
m.scrollOffTopPosition = m.top.findNode("scrollOffTopPosition")
m.scrollOffTopOpacity = m.top.findNode("scrollOffTopOpacity")
m.scrollOffBottomAnimation = m.top.findNode("scrollOffBottomAnimation")
m.scrollOffBottomPosition = m.top.findNode("scrollOffBottomPosition")
m.scrollOffBottomOpacity = m.top.findNode("scrollOffBottomOpacity")
2022-09-27 01:26:17 +00:00
m.scrollUpToOnDeckAnimation = m.top.findNode("scrollUpToOnDeckAnimation")
m.scrollUpToOnDeckPosition = m.top.findNode("scrollUpToOnDeckPosition")
m.scrollDownToOnDeckAnimation = m.top.findNode("scrollDownToOnDeckAnimation")
m.scrollDownToOnDeckPosition = m.top.findNode("scrollDownToOnDeckPosition")
m.scrollOffOnDeckAnimation = m.top.findNode("scrollOffOnDeckAnimation")
m.scrollOffOnDeckPosition = m.top.findNode("scrollOffOnDeckPosition")
m.top.observeField("translation", "onTranslationChange")
2022-09-03 20:06:57 +00:00
m.top.observeField("id", "onIDChange")
m.top.observeField("focusedChild", "onFocusChange")
end sub
sub onIDChange()
m.showFromBottomPosition.fieldToInterp = m.top.id + ".translation"
m.showFromBottomOpacity.fieldToInterp = m.top.id + ".opacity"
m.showFromTopPosition.fieldToInterp = m.top.id + ".translation"
m.showFromTopOpacity.fieldToInterp = m.top.id + ".opacity"
m.scrollOffTopPosition.fieldToInterp = m.top.id + ".translation"
m.scrollOffTopOpacity.fieldToInterp = m.top.id + ".opacity"
m.scrollOffBottomPosition.fieldToInterp = m.top.id + ".translation"
m.scrollOffBottomOpacity.fieldToInterp = m.top.id + ".opacity"
2022-09-27 01:26:17 +00:00
m.scrollUpToOnDeckPosition.fieldToInterp = m.top.id + ".translation"
m.scrollDownToOnDeckPosition.fieldToInterp = m.top.id + ".translation"
m.scrollOffOnDeckPosition.fieldToInterp = m.top.id + ".translation"
end sub
sub onTranslationChange()
m.startingPosition = m.top.translation
m.scrollOffBottomPosition.keyValue = "[[0, 0], [" + str(m.startingPosition[0]) + ", " + str(m.startingPosition[1]) + "]]"
m.top.unobserveField("translation")
2022-09-03 20:06:57 +00:00
end sub
sub showFromTop()
m.showFromTopAnimation.control = "start"
end sub
sub showFromBottom()
m.showFromBottomAnimation.control = "start"
end sub
sub scrollOffBottom()
m.scrollOffBottomAnimation.control = "start"
end sub
sub scrollOffTop()
m.scrollOffTopAnimation.control = "start"
end sub
2022-09-27 01:26:17 +00:00
sub scrollUpToOnDeck()
m.scrollUpToOnDeckAnimation.control = "start"
end sub
sub scrollDownToOnDeck()
m.scrollDownToOnDeckAnimation.control = "start"
end sub
sub scrollOffOnDeck()
m.scrollOffOnDeckAnimation.control = "start"
end sub
2022-09-03 20:06:57 +00:00
sub onFocusChange()
defaultFocusElement = m.top.findNode(m.top.defaultFocusID)
if isValid(defaultFocusElement)
defaultFocusElement.setFocus(m.top.isInFocusChain())
if isValid(defaultFocusElement.focus)
defaultFocusElement.focus = m.top.isInFocusChain()
end if
end if
end sub