modules.getItemTransparency=function(l)return function(b,A,L)local K=l.state.selectedIndex==A and b==L local a=L-b return l.position:map(function(b)if not l.isAnimating then return K and TRANSPARENCY_SELECTED or TRANSPARENCY_NOT_SELECTED end local L=0 if l.target:getValue()~=0 then L=b/l.target:getValue()end local Z if K then Z=L*TRANSPARENCY_NOT_SELECTED elseif l.formatTargetIndex(A,a)==l.targetIndex then Z=TRANSPARENCY_NOT_SELECTED*(1-L)else Z=TRANSPARENCY_NOT_SELECTED end return Z end)end end return modules

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
