Thanks a ton dude !
I like the wave effect. So I managed it a bit to get what I needed with auto-positioning and it look pretty well.
I did not use the " view = scrolllView:getView() " but rather a common table including all my stuff because I don’t control it, to what i’ve understood is the scrollView table, isnt it ?
so I publish my code if it can help someone else.
local screen = require "Data.screenData" local myData = require "Data.myData" local widget = require "widget" --"here there're all my object inserted from an other page" local objShop = {} local levelSelectGroup local scaleWithinDist = display.actualContentWidth \* .2 local minScale, maxScale = 0.8 ,1.6 local scaleDiff = maxScale - minScale local boutiqueFrame = function() local velocity = math.abs(levelSelectGroup.\_view.\_velocity) --print(velocity, "velocity") for j = 1,#objShop do local item = objShop[j] if item ~= nil then --"scaling object" local x, y = item:localToContent( 0, 0 ) local dist = math.abs( screen.centerX - x ) if (dist \> scaleWithinDist) then item.xScale, item.yScale = minScale, minScale else local factor = 1 - (dist / scaleWithinDist) local scale = minScale + factor \* scaleDiff item.xScale, item.yScale = scale, scale end --"auto-positioning object in the middle" if item.xScale \>= 1.27 and item.xScale \< maxScale then local itemIdx = j-1 local between = (objShop[2].x - objShop[1].x) if velocity \<= 1.3 and not myData.velocity and not myData.scrollTo then myData.scrollTo = true myData.velocity = true levelSelectGroup:scrollToPosition {x = -between \* itemIdx, time = 190, onComplete = function()myData.scrollTo = false end} end end end end end local function scrollListener( event ) local phase = event.phase if ( phase == "began" ) then myData.velocity = true elseif ( phase == "moved" ) then elseif ( phase == "ended" or phase == "cancelled" ) then myData.velocity = false end if ( event.limitReached ) then if ( event.direction == "left" ) then levelSelectGroup.\_view.\_velocity = 0 elseif ( event.direction == "right" ) then levelSelectGroup.\_view.\_velocity = 0 end end return true end levelSelectGroup = widget.newScrollView({ width = display.contentWidth, height = display.contentHeight, isLocked = false, friction = 0.976, isBounceEnabled = true, hideBackground = true, hideScrollBar = false, verticalScrollDisabled = true, listener = scrollListener }) levelSelectGroup.x = display.contentCenterX levelSelectGroup.y = display.contentCenterY Runtime:addEventListener("enterFrame", boutiqueFrame )
Last thing, Do you know if you can cancel the scrollToPosition, I tried to do " transition.cancel() " but it does no effect, so if I increase his time it makes me some bug because the transition is not done.
Hope that could help ! if you have some advices to improve it, I get them.