<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import {
  getSlideHeight,
  getAlignmentOffset
} from '../utilities/style-utilities';
import {
  getSlideDirection,
  handleSelfFocus,
  getSlideClassName,
  isFullyVisible
} from '../utilities/utilities';

const MIN_ZOOM_SCALE = 0;
const MAX_ZOOM_SCALE = 1;

export default class ScrollTransition extends React.Component {
  constructor(props) {
    super(props);
    this.getListStyles = this.getListStyles.bind(this);
  }

  /* eslint-disable complexity */
  getSlideTargetPosition(currentSlideIndex, positionValue) {
    let offset = 0;

    if (
      this.props.animation === 'zoom' &&
      (this.props.currentSlide === currentSlideIndex + 1 ||
        (this.props.currentSlide === 0 &&
          currentSlideIndex === this.props.children.length - 1))
    ) {
      offset = this.props.slideOffset;
    } else if (
      this.props.animation === 'zoom' &&
      (this.props.currentSlide === currentSlideIndex - 1 ||
        (this.props.currentSlide === this.props.children.length - 1 &&
          currentSlideIndex === 0))
    ) {
      offset = -this.props.slideOffset;
    }

    let targetPosition =
      (this.props.slideWidth + this.props.cellSpacing) * currentSlideIndex;

    const alignmentOffset = getAlignmentOffset(currentSlideIndex, this.props);
    const relativePosition = positionValue - alignmentOffset;
    const startSlideIndex = Math.min(
      Math.abs(Math.floor(relativePosition / this.props.slideWidth)),
      this.props.slideCount - 1
    );

    if (this.props.wrapAround && currentSlideIndex !== startSlideIndex) {
      const slidesOutOfView = Math.max(
        this.props.slideCount -
          Math.ceil(this.props.frameWidth / this.props.slideWidth), // Total slides in view
        0
      );<commit_msg>allow peeking slides when slide count is less than 3 (#746)<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import {
  getSlideHeight,
  getAlignmentOffset
} from '../utilities/style-utilities';
import {
  getSlideDirection,
  handleSelfFocus,
  getSlideClassName,
  isFullyVisible
} from '../utilities/utilities';

const MIN_ZOOM_SCALE = 0;
const MAX_ZOOM_SCALE = 1;

export default class ScrollTransition extends React.Component {
  constructor(props) {
    super(props);
    this.getListStyles = this.getListStyles.bind(this);
  }

  /* eslint-disable complexity */
  getSlideTargetPosition(currentSlideIndex, positionValue) {
    let offset = 0;
    // Below lines help to display peeking slides when number of slides is less than 3.
    let peekSlide = true;
    switch (this.props.cellAlign) {
      case 'left':
        peekSlide =
          this.props.children.length <= 2 && currentSlideIndex !== 0
            ? false
            : true;
        break;
      case 'center':
        peekSlide =
          this.props.children.length > 2 ||
          this.props.currentSlide !== currentSlideIndex - 1
            ? true
            : false;
        break;
    }

    if (
      this.props.animation === 'zoom' &&
      peekSlide &&
      (this.props.currentSlide === currentSlideIndex + 1 ||
        (this.props.currentSlide === 0 &&
          currentSlideIndex === this.props.children.length - 1))
    ) {
      offset = this.props.slideOffset;
    } else if (
      this.props.animation === 'zoom' &&
      (this.props.currentSlide === currentSlideIndex - 1 ||
        (this.props.currentSlide === this.props.children.length - 1 &&
          currentSlideIndex === 0))
    ) {
      offset = -this.props.slideOffset;
    }

    let targetPosition =
      (this.props.slideWidth + this.props.cellSpacing) * currentSlideIndex;

    const alignmentOffset = getAlignmentOffset(currentSlideIndex, this.props);
    const relativePosition = positionValue - alignmentOffset;
    const startSlideIndex = Math.min(
      Math.abs(Math.floor(relativePosition / this.props.slideWidth)),
      this.props.slideCount - 1
    );

    if (this.props.wrapAround && currentSlideIndex !== startSlideIndex) {
      const slidesOutOfView = Math.max(
        this.props.slideCount -
          Math.ceil(this.props.frameWidth / this.props.slideWidth), // Total slides in view
        0
      );
{'fraction_non_alphanumeric': 0.11536643026004728, 'fraction_numerical': 0.007328605200945627, 'mean_word_length': 2.767586821015138, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1541966', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1242, 'n_words': 262}