28 function getContinuousIndex(x, tileWidth, gapToMiddlePhase, gapToEndPhase, kGapEnd, kMiddleIndex, kXBeginningEnd) {
29 if (x < gapToMiddlePhase) {
31 return x * kXBeginningEnd
32 }
else if (x > gapToEndPhase) {
34 return x * kXBeginningEnd + kGapEnd
38 return x / tileWidth + kMiddleIndex
50 function getXFromContinuousIndex(index, viewWidth, contentWidth, tileWidth, gapToMiddlePhase, gapToEndPhase, drawBuffer) {
51 var middleX = (index + 0.5) * tileWidth - viewWidth / 2
53 if (middleX < gapToMiddlePhase) {
57 (viewWidth / (2 * tileWidth * gapToMiddlePhase)) -
58 1 / (2 * gapToMiddlePhase))
60 }
else if (middleX > gapToEndPhase) {
64 viewWidth / tileWidth +
65 (contentWidth * viewWidth - viewWidth * viewWidth) / (2 * tileWidth * gapToMiddlePhase) +
66 (viewWidth - contentWidth) / (2 * gapToMiddlePhase)) /
68 viewWidth / (2 * tileWidth * gapToMiddlePhase) -
69 1 / (2 * gapToMiddlePhase))
74 return middleX - drawBuffer
83 function getViewTranslation(x, tileWidth, gapToMiddlePhase, gapToEndPhase, translationXViewFactor) {
84 if (x < gapToMiddlePhase) {
86 return (gapToMiddlePhase - x) * translationXViewFactor
87 }
else if (x > gapToEndPhase) {
89 return (gapToEndPhase - x) * translationXViewFactor
102 function getItemScale(distance, continuousIndex, numberOfItems, scaleFactor) {
103 var distanceAbs = Math.abs(distance)
104 var distanceToBounds = Math.min(continuousIndex, numberOfItems - continuousIndex)
105 var k = Math.max(200 + 100 * (-distanceToBounds / (3 * scaleFactor)), 50)
106 return Math.max(0.01, 1 - Math.pow(distanceAbs, 2.5) / (k * scaleFactor))
117 function getItemTranslation(index, selectedIndex, distance, scale, maxScale, maxTranslation) {
118 if (index === selectedIndex)
return 0
119 var sign = distance > 0 ? 1 : -1
120 return sign * (maxScale - scale) * maxTranslation