Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VaSlider): prevent slider for overflowing from track #4293

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

ahmadJT
Copy link
Contributor

@ahmadJT ahmadJT commented May 29, 2024

Description

  • prevent slider for overflowing from track

Fixes

#4291

Markup:

// Your code


const processedStyles = computed(() => {
  if (Array.isArray(val.value)) {
    const val0 = ((val.value[0] - minComputed.value) / (maxComputed.value - minComputed.value)) * 100
    const val1 = ((val.value[1] - minComputed.value) / (maxComputed.value - minComputed.value)) * 100

    return {
      [pinPositionStyle.value]: `${val0}%`,
      [trackSizeStyle.value]: `${val1 - val0}%`,
      backgroundColor: getColor(props.color),
      visibility: props.showTrack ? 'visible' : 'hidden',
    } as CSSProperties
  } else {
    const val0 = ((val.value - minComputed.value) / (maxComputed.value - minComputed.value)) * 100

    return {
      [trackSizeStyle.value]: `${val0 > 100 ? 100 : val0}%`,
      backgroundColor: getColor(props.color),
      visibility: props.showTrack ? 'visible' : 'hidden',
    } as CSSProperties
  }
})

const dottedStyles = computed(() => {
  if (Array.isArray(val.value)) {
    const val0 = ((val.value[0] - minComputed.value) / (maxComputed.value - minComputed.value)) * 100
    const val1 = ((val.value[1] - minComputed.value) / (maxComputed.value - minComputed.value)) * 100

    return [
      {
        [pinPositionStyle.value]: `${val0}%`,
        backgroundColor: isActiveDot(0) ? getColor(props.color) : '#ffffff',
        borderColor: getColor(props.color),
      },
      {
        [pinPositionStyle.value]: `${val1}%`,
        backgroundColor: isActiveDot(1) ? getColor(props.color) : '#ffffff',
        borderColor: getColor(props.color),
      },
    ] as CSSProperties[]
  } else {
    const val0 = ((val.value - minComputed.value) / (maxComputed.value - minComputed.value)) * 100

    return {
      [pinPositionStyle.value]: `${val0 > 100 ? 100 : val0}%`,
      backgroundColor: isActiveDot(0) ? getColor(props.color) : '#ffffff',
      borderColor: getColor(props.color),
    } as CSSProperties
  }
})

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any feature but make things better)

Copy link
Collaborator

@m0ksem m0ksem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@m0ksem m0ksem merged commit df61194 into epicmaxco:develop Jun 3, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants