modules.getItemTransparency=function(Q)return function(T,S,w)local t=Q.state.selectedIndex==S and T==w local j=w-T return Q.position:map(function(T)if not Q.isAnimating then return t and TRANSPARENCY_SELECTED or TRANSPARENCY_NOT_SELECTED end local w=0 if Q.target:getValue()~=0 then w=T/Q.target:getValue()end local A if t then A=w*TRANSPARENCY_NOT_SELECTED elseif Q.formatTargetIndex(S,j)==Q.targetIndex then A=TRANSPARENCY_NOT_SELECTED*(1-w)else A=TRANSPARENCY_NOT_SELECTED end return A end)end end return modules
--[[
	Returns the item transparency binding for a single item.

	Used for coordinating slide + fade animations: image should fade to the inactive state as we are sliding.
]]
modules.getItemTransparency = function(self)
	return function(renderedIndex, index, mid)
		-- Avoid the same image being shown as selected when they are shown on the same page
		local isSelected = self.state.selectedIndex == index and renderedIndex == mid

		-- Offset from the current selected index
		local offset = mid - renderedIndex

		return self.position:map(function(position)
			if not self.isAnimating then
				return isSelected and TRANSPARENCY_SELECTED or TRANSPARENCY_NOT_SELECTED
			end

			local progress = 0
			if self.target:getValue() ~= 0 then
				progress = position / self.target:getValue()
			end

			local res
			if isSelected then
				-- Current selected (we should fade this out since we only set state AFTER the position
				-- animation completes)
				res = progress * TRANSPARENCY_NOT_SELECTED
			elseif self.formatTargetIndex(index, offset) == self.targetIndex then
				-- Target rendered index that we want to get to
				res = TRANSPARENCY_NOT_SELECTED * (1 - progress)
			else
				-- Every other image
				res = TRANSPARENCY_NOT_SELECTED
			end

			return res
		end)
	end
end

return modules
