2.0.2 • Published 9 months ago

@frankhoodbs/scroll-progress-helper v2.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Scroll Progress Helper

Scroll Progress Helper is a utility for Vue 3 applications that provides a composable function to calculate and track the scroll progress between specified elements. It allows you to monitor the user's scroll position and integrate dynamic behaviors based on the scroll progress within your Vue components.

Version License

Installation

Install the utility using npm:

npm install @frankhoodbs/scroll-progress-helper

Usage

Import the utility in your Vue component:

import useScrollProgressHelper from '@frankhoodbs/scroll-progress-helper';

Use the utility within your component:

const { progress } = useScrollProgressHelper({
  startElement: HTMLNodeOrRef, /* your start element reference */
  endElement: HTMLNodeOrRef, /* your end element reference */
  // Additional configuration options if needed
});

Access the scroll progress:

// Reactively access the scroll progress as a computed property
console.log(progress.value); // Current scroll progress as a percentage (0 to 100)

Configuration Options

OptionDescriptionDefault Value
scrollerThe element used as the scroll container.window
startElementThe reference to the starting element for scroll tracking.-
startTriggerPointThe trigger point within the starting element ('start' or 'end').'start'
endElementThe reference to the ending element for scroll tracking.-
endTriggerPointThe trigger point within the ending element ('start' or 'end').'end'
scrollerIntersectionPointPercentage of the scroller height used to determine intersection.50

Example

<template>
    <div class="App">
        <div ref="$start">...</div>
        <div ref="$end">...</div>
        <progress class="progress" :value="progress" max="100">{{ progress }}%</progress>
    </div>
</template>

<script setup lang="ts">
import useScrollProgressHelper from '@frankhoodbs/scroll-progress-helper';
import { ref } from 'vue';

const $start = ref<HTMLElement | null>(null);
const $end = ref<HTMLElement | null>(null);

const { progress } = useScrollProgressHelper({
  startElement: $start,
  endElement: $end,
});
</script>
2.0.2

9 months ago

1.1.12

9 months ago

2.0.1

9 months ago

1.1.11

10 months ago

1.1.9

12 months ago

1.1.10

12 months ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago