Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

swipe with scrollview
Started by jjrey95 May 13 2019 10:52 AM

No replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jjrey95

[GLOBAL: userInfoPane.html]
jjrey95
  • Observer

  • 29 posts
  • Corona SDK

Good afternoon,

I need to create a kind of box that can be used as a swipe, I have tried to do with a scrollview, the problem I have is that when I condition it so that it does not move vertically but only horizontally it keeps moving, in the same way I need only can move to the left, but I have not achieved this. Thank you.

 

scrollview_horarios=widget.newScrollView(
        {   
        top = text_actividad.y+text_actividad.height+150,
        left = 0,
        width = 768,
        height =200,
        hideBackground=true,
        horizontalScrollDisabled=false,
        verticalScrollDisabled=true,  
        listener=handleButtonEvent
        }
    )   
 
    scrollview_horarios.x=display.contentCenterX
 

function handleButtonEvent(event)
 
if(event.phase=="moved")then
 
direction = event.direction
dx=math.abs(event.x-event.xStart)
dy=math.abs((event.y-event.yStart))
 
 
print("dx"..dx)
print("dy"..dy)
 
if "right" == direction then
    scrollview_horarios:setIsLocked(true)
    transition.moveTo(fondo_horarios,{x=position1x, y=position1y, time=4})
    if(math.abs((event.x-event.xStart))>0)then
      scrollview_horarios:setIsLocked(true)
fondo_borrar.alpha=0
icono_borrar.alpha=0
end
elseif "left" ==direction then
scrollview_horarios:setIsLocked(false)
transition.moveTo(fondo_horarios,{x=position1x, y=position1y, time=4})
if(dx>20 and dx<1060 )then
--scrollview_horarios:takeFocus(event)
 
fondo_borrar.alpha=1
icono_borrar.alpha=1
--fondo_borrar.width=display.viewableContentWidth-100
--fondo_borrar.x=display.contentCenterX
end
if(dx>230)then
scrollview_horarios:setIsLocked(true)
transition.moveTo(fondo_horarios, {x=position1x, y=posiciony, time=4})
--fondo_borrar.alpha=0
--icono_borrar.alpha=0
end
elseif "up"  == direction then
 
scrollview_horarios:setIsLocked(true)
transition.moveTo(fondo_horarios,{x=position1x, y=position1y, time=4})
if(dy>0)then
scrollview_horarios:setIsLocked(true)
fondo_borrar.alpha=0
end
elseif "down" == direction then
 
if(dy>0)then
scrollview_horarios:setIsLocked(true)
fondo_borrar.alpha=0
transition.moveTo(fondo_horarios,{x=position1x, y=position1y, time=4})
end
end
if(dx>0 and dy==0)then
scrollview_horarios:setIsLocked(false)
end
print(position1x)
print(position1y)
elseif(event.phase=="ended")then
 
end
end

 

 




[topic_controls]
[/topic_controls]